Merge "Don't warn on network-vif-unplugged event during live migration" into stable/rocky
This commit is contained in:
commit
6a7c639b9b
|
@ -8092,13 +8092,21 @@ class ComputeManager(manager.Manager):
|
|||
_event.send(event)
|
||||
else:
|
||||
# If it's a network-vif-unplugged event and the instance is being
|
||||
# deleted then we don't need to make this a warning as it's
|
||||
# expected. There are other things which could trigger this like
|
||||
# detaching an interface, but we don't have a task state for that.
|
||||
# deleted or live migrated then we don't need to make this a
|
||||
# warning as it's expected. There are other expected things which
|
||||
# could trigger this event like detaching an interface, but we
|
||||
# don't have a task state for that.
|
||||
# TODO(mriedem): We have other move operations and things like
|
||||
# hard reboot (probably rebuild as well) which trigger this event
|
||||
# but nothing listens for network-vif-unplugged. We should either
|
||||
# handle those other known cases or consider just not logging a
|
||||
# warning if we get this event and the instance is undergoing some
|
||||
# task state transition.
|
||||
if (event.name == 'network-vif-unplugged' and
|
||||
instance.task_state == task_states.DELETING):
|
||||
LOG.debug('Received event %s for instance which is being '
|
||||
'deleted.', event.key, instance=instance)
|
||||
instance.task_state in (
|
||||
task_states.DELETING, task_states.MIGRATING)):
|
||||
LOG.debug('Received event %s for instance with task_state %s.',
|
||||
event.key, instance.task_state, instance=instance)
|
||||
else:
|
||||
LOG.warning('Received unexpected event %(event)s for '
|
||||
'instance with vm_state %(vm_state)s and '
|
||||
|
|
|
@ -2810,14 +2810,17 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
|||
self.assertEqual(event_obj, event.wait())
|
||||
self.assertEqual({}, self.compute.instance_events._events)
|
||||
|
||||
@ddt.data(task_states.DELETING,
|
||||
task_states.MIGRATING)
|
||||
@mock.patch('nova.compute.manager.LOG')
|
||||
def test_process_instance_event_deleting(self, mock_log):
|
||||
def test_process_instance_event_expected_task(self, task_state, mock_log):
|
||||
"""Tests that we don't log a warning when we get a
|
||||
network-vif-unplugged event for an instance that's being deleted.
|
||||
network-vif-unplugged event for an instance that's undergoing a task
|
||||
state transition that will generate the expected event.
|
||||
"""
|
||||
inst_obj = objects.Instance(uuid=uuids.instance,
|
||||
vm_state=vm_states.ACTIVE,
|
||||
task_state=task_states.DELETING)
|
||||
task_state=task_state)
|
||||
event_obj = objects.InstanceExternalEvent(name='network-vif-unplugged',
|
||||
tag=uuids.port_id)
|
||||
with mock.patch.object(self.compute.instance_events,
|
||||
|
@ -2827,8 +2830,8 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
|||
mock_log.debug.assert_called()
|
||||
self.assertThat(mock_log.debug.call_args[0][0],
|
||||
testtools.matchers.MatchesRegex(
|
||||
'Received event .* for instance which is being '
|
||||
'deleted.'))
|
||||
'Received event .* for instance with task_state '
|
||||
'%s'))
|
||||
|
||||
@mock.patch('nova.compute.manager.LOG')
|
||||
def test_process_instance_event_unexpected_warning(self, mock_log):
|
||||
|
|
Loading…
Reference in New Issue