Trivial: improve failover logging

We log a warning when detecting a failover for which the destination
host matches the one that's already set in the Nova db. Some times
this means that instance bounced between hosts but most of the times
this is just a migration initiated by Nova, which already updated
the DB.

While at it, when the driver initializes, we'll log the list of
detected failovers before asynchronously handling them.

Change-Id: I808c8cb63ac0011be8d6824a2f8e9292fe39004f
This commit is contained in:
Lucian Petrut 2019-09-03 13:45:17 +03:00
parent 20c1b2083f
commit bf39a47dbe
2 changed files with 12 additions and 8 deletions

View File

@ -105,7 +105,10 @@ class ClusterOps(object):
# filter out instances that are known to be on this host.
nova_instances = [instance for instance in nova_instances if
self._this_node.upper() != instance.host.upper()]
instance_names = [instance.name for instance in nova_instances]
LOG.warning("Handling failovers that occurred while Nova was not "
"running: %s", instance_names)
for instance in nova_instances:
utils.spawn_n(self._failover_migrate,
instance.name,
@ -151,19 +154,18 @@ class ClusterOps(object):
migrated_here = new_host.upper() == self._this_node.upper()
migrated_from_here = old_host.upper() == self._this_node.upper()
if instance.task_state == task_states.MIGRATING:
LOG.debug('Instance %s is being migrated by Nova. This '
'will not be treated as a failover.',
instance_name)
return
if not host_changed:
LOG.warning("The source node is the same as the destination "
"node: %(host)s. The instance %(instance)s may have "
"bounced between hosts due to a failure.",
dict(host=old_host, instance=instance_name))
if instance.task_state == task_states.MIGRATING:
# In case of live migration triggered by the user, we get the
# event that the instance changed host but we do not want
# to treat it as a failover.
LOG.debug('Instance %s is live migrating.', instance_name)
return
nw_info = self._network_api.get_instance_nw_info(self._context,
instance)
if host_changed and migrated_from_here:

View File

@ -178,7 +178,9 @@ class ClusterOpsTestCase(test_base.HyperVBaseTestCase):
'new_host')
mock_LOG.debug.assert_called_once_with(
'Instance %s is live migrating.', mock.sentinel.instance_name)
'Instance %s is being migrated by Nova. This '
'will not be treated as a failover.',
mock.sentinel.instance_name)
@mock.patch.object(clusterops.ClusterOps, '_wait_for_pending_instance')
@mock.patch.object(clusterops.ClusterOps, '_get_instance_by_name')