Fix endless periodic looping call after failed evacuation

Fixes an issue where a failed evacuation could result in a periodic
looping call to run forever. This happened because the periodic call was
not stopped after a timeout occurred.

Change-Id: Id3b9bad4bc617c168200d34d69bbe760a24dfcf9
Closes-Bug: #1897888
This commit is contained in:
Mark Goddard 2020-09-30 13:52:04 +01:00 committed by suzhengwei
parent 3fcadf85c7
commit df63714b03
2 changed files with 15 additions and 10 deletions

View File

@ -178,11 +178,10 @@ class EvacuateInstancesTask(base.MasakariTask):
periodic_call_stopped.wait)
except etimeout.Timeout:
with excutils.save_and_reraise_exception():
periodic_call_stopped.stop()
msg = ("Instance '%(uuid)s' is successfully evacuated but "
"failed to stop.") % {'uuid': instance.id}
"timeout to stop.") % {'uuid': instance.id}
LOG.warning(msg)
else:
finally:
periodic_call_stopped.stop()
def _evacuate_and_confirm(self, context, instance, host_name,
@ -224,13 +223,12 @@ class EvacuateInstancesTask(base.MasakariTask):
etimeout.with_timeout(
CONF.wait_period_after_evacuation,
periodic_call.wait)
except exception.InstanceEvacuateFailed as e:
LOG.warning(str(e))
failed_evacuation_instances.append(instance.id)
except etimeout.Timeout:
# Instance is not evacuated in the expected time_limit.
failed_evacuation_instances.append(instance.id)
else:
with excutils.save_and_reraise_exception():
msg = ("Timeout for instance '%(uuid)s' evacuation."
% {'uuid': instance.id})
LOG.warning(msg)
finally:
# stop the periodic call, in case of exceptions or
# Timeout.
periodic_call.stop()
@ -277,9 +275,10 @@ class EvacuateInstancesTask(base.MasakariTask):
except etimeout.Timeout:
# Instance is not stop in the expected time_limit.
failed_evacuation_instances.append(instance.id)
except Exception:
except Exception as e:
# Exception is raised while resetting instance state or
# evacuating the instance itself.
LOG.warning(str(e))
failed_evacuation_instances.append(instance.id)
finally:
if not instance_already_locked:

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixes an issue where a periodic task in Masakari Engine could loop forever
querying Nova API following a failed evacuation. `LP#1897888
<https://bugs.launchpad.net/masakari/+bug/1897888>`__