Fix guest heartbeat post notification not sent for resize-revert
Issue is Post Notification is not sent after resize-revert if resize-revert is moving the instance to a new host. Introduced max_resize_wait_in_secs and handling of the potential host change event. Also fixed a few VIM scenario tests failures due to nfv_vim_instance_guest_services_post_notify_heartbeat not found. Change-Id: I89064a6856bc90d18e5d0f51f9eb3a41a951b1a8
This commit is contained in:
parent
da93ce42c7
commit
1370e9d948
@ -38,6 +38,7 @@ max_live_migrate_wait_in_secs=800
|
||||
max_live_migrate_wait_in_secs_min=120
|
||||
max_live_migrate_wait_in_secs_max=800
|
||||
max_cold_migrate_wait_in_secs=900
|
||||
max_resize_wait_in_secs=900
|
||||
max_evacuate_wait_in_secs=900
|
||||
max_cold_migrate_local_image_disk_gb=60
|
||||
max_cold_migrate_local_lvm_disk_gb=20
|
||||
|
@ -1021,9 +1021,12 @@ class NotifyInstancesHostDisablingTaskWork(state_machine.StateTaskWork):
|
||||
int(section.get('max_live_migrate_wait_in_secs_max', 800))
|
||||
max_cold_migrate_wait_in_secs = \
|
||||
int(section.get('max_cold_migrate_wait_in_secs', 900))
|
||||
max_resize_wait_in_secs = \
|
||||
int(section.get('max_resize_wait_in_secs', 900))
|
||||
max_migrate_wait_in_secs = max(
|
||||
max_live_migrate_wait_in_secs_max,
|
||||
max_cold_migrate_wait_in_secs)
|
||||
max_cold_migrate_wait_in_secs,
|
||||
max_resize_wait_in_secs)
|
||||
else:
|
||||
max_migrate_wait_in_secs = 900
|
||||
# Add 60s to ensure the migration will time out before task
|
||||
|
@ -61,6 +61,7 @@ class EventNames(object):
|
||||
GUEST_ACTION_PROCEED = Constant('guest-action-proceed')
|
||||
GUEST_COMMUNICATION_ESTABLISHED = Constant('guest-communication-established')
|
||||
LIVE_MIGRATE_ROLLBACK = Constant('live-migrate-rollback')
|
||||
RESIZE_REVERT_COMPLETED = Constant('resize-revert-completed')
|
||||
AUDIT = Constant('audit')
|
||||
TASK_START = Constant('task-start')
|
||||
TASK_STOP = Constant('task-stop')
|
||||
|
@ -556,6 +556,7 @@ class ResizeRevertTaskWork(state_machine.StateTaskWork):
|
||||
'resize-revert-instance_%s' % instance.name, task,
|
||||
force_pass=force_pass, timeout_in_secs=60)
|
||||
self._instance_reference = weakref.ref(instance)
|
||||
self._from_host_name = instance.host_name
|
||||
|
||||
@property
|
||||
def _instance(self):
|
||||
@ -575,9 +576,18 @@ class ResizeRevertTaskWork(state_machine.StateTaskWork):
|
||||
DLOG.debug("Resize-Revert-Instance callback for %s, "
|
||||
"response=%s." % (self._instance.name, response))
|
||||
if response['completed']:
|
||||
self.task.task_work_complete(
|
||||
state_machine.STATE_TASK_WORK_RESULT.SUCCESS,
|
||||
empty_reason)
|
||||
# A resize revert might causes a movement of the instance back
|
||||
# to the original host. Need to wait for this movement to
|
||||
# complete.
|
||||
if 0 == self._instance.max_resize_wait_in_secs:
|
||||
DLOG.verbose("Resize-Revert-Instance instance has a "
|
||||
"timeout of zero, not waiting.")
|
||||
self.task.task_work_complete(
|
||||
state_machine.STATE_TASK_WORK_RESULT.SUCCESS,
|
||||
empty_reason)
|
||||
else:
|
||||
self.extend_timeout(
|
||||
self._instance.max_resize_wait_in_secs)
|
||||
else:
|
||||
if self.force_pass:
|
||||
DLOG.info("Resize-Revert-Instance callback for %s, "
|
||||
@ -612,6 +622,32 @@ class ResizeRevertTaskWork(state_machine.StateTaskWork):
|
||||
|
||||
return state_machine.STATE_TASK_WORK_RESULT.WAIT, empty_reason
|
||||
|
||||
def handle_event(self, event, event_data=None):
|
||||
"""
|
||||
Handle instance action proceed notifications
|
||||
"""
|
||||
handled = False
|
||||
|
||||
if INSTANCE_EVENT.NFVI_HOST_CHANGED == event:
|
||||
if self._from_host_name != self._instance.host_name:
|
||||
DLOG.debug("Resize-Revert-Instance for %s has moved from "
|
||||
"host %s to host %s." % (self._instance.name,
|
||||
self._from_host_name,
|
||||
self._instance.host_name))
|
||||
self.task.task_work_complete(
|
||||
state_machine.STATE_TASK_WORK_RESULT.SUCCESS,
|
||||
empty_reason)
|
||||
handled = True
|
||||
|
||||
elif INSTANCE_EVENT.RESIZE_REVERT_COMPLETED == event:
|
||||
DLOG.debug("Resize-Revert-Instance for %s completed"
|
||||
% self._instance.name)
|
||||
self.task.task_work_complete(
|
||||
state_machine.STATE_TASK_WORK_RESULT.SUCCESS,
|
||||
empty_reason)
|
||||
handled = True
|
||||
return handled
|
||||
|
||||
|
||||
class EvacuateTaskWork(state_machine.StateTaskWork):
|
||||
"""
|
||||
@ -2225,6 +2261,10 @@ class GuestServicesPostNotifyTaskWork(state_machine.StateTaskWork):
|
||||
self._action_type))
|
||||
|
||||
if guest_services.guest_communication_established():
|
||||
# this log is needed for nfv_scenario_tests
|
||||
DLOG.debug("Guest-Services-Post-Notify for %s, guest "
|
||||
"communication re-established." % self._instance.name)
|
||||
|
||||
DLOG.debug("Guest-Services-Post-Notify for %s, action_type=%s."
|
||||
% (self._instance.name, self._action_type))
|
||||
|
||||
|
@ -812,6 +812,7 @@ class Instance(ObjectData):
|
||||
self._max_live_migrate_wait_in_secs = None
|
||||
self._max_live_migration_downtime_in_ms = None
|
||||
self._max_cold_migrate_wait_in_secs = None
|
||||
self._max_resize_wait_in_secs = None
|
||||
self._max_evacuate_wait_in_secs = None
|
||||
self._deleted = False
|
||||
self._fail_reason = None
|
||||
@ -1401,6 +1402,27 @@ class Instance(ObjectData):
|
||||
% (self._max_cold_migrate_wait_in_secs, self.name))
|
||||
return self._max_cold_migrate_wait_in_secs
|
||||
|
||||
@property
|
||||
def max_resize_wait_in_secs(self):
|
||||
"""
|
||||
Returns the resize timeout value for this instance
|
||||
"""
|
||||
if self._max_resize_wait_in_secs is not None:
|
||||
DLOG.debug("Resize timeout is %s secs for %s."
|
||||
% (self._max_resize_wait_in_secs, self.name))
|
||||
return self._max_resize_wait_in_secs
|
||||
|
||||
if config.section_exists('instance-configuration'):
|
||||
section = config.CONF['instance-configuration']
|
||||
self._max_resize_wait_in_secs = \
|
||||
int(section.get('max_resize_wait_in_secs', 900))
|
||||
else:
|
||||
self._max_resize_wait_in_secs = 900
|
||||
|
||||
DLOG.debug("Resize timeout set to %s secs for %s."
|
||||
% (self._max_resize_wait_in_secs, self.name))
|
||||
return self._max_resize_wait_in_secs
|
||||
|
||||
@property
|
||||
def max_evacuate_wait_in_secs(self):
|
||||
"""
|
||||
@ -2786,6 +2808,16 @@ class Instance(ObjectData):
|
||||
# There is not an action in progress, mark action as completed.
|
||||
self._action_data.set_action_completed()
|
||||
|
||||
elif self._action_data.is_completed():
|
||||
if INSTANCE_ACTION_TYPE.REVERT_RESIZE == action_type:
|
||||
DLOG.debug("Resize-Revert-Instance for instance %s completed."
|
||||
% self.name)
|
||||
self._action_fsm.handle_event(
|
||||
instance_fsm.INSTANCE_EVENT.RESIZE_REVERT_COMPLETED)
|
||||
else:
|
||||
DLOG.info("Ignoring action for instance %s, action_type=%s, "
|
||||
"action-state %s." % (self.name, action_type,
|
||||
action_state))
|
||||
else:
|
||||
DLOG.info("Ignoring action for instance %s, action_type=%s, "
|
||||
"action-state %s." % (self.name, action_type,
|
||||
@ -2804,13 +2836,25 @@ class Instance(ObjectData):
|
||||
if not self._action_data.is_inprogress():
|
||||
return
|
||||
|
||||
if INSTANCE_ACTION_TYPE.LIVE_MIGRATE_ROLLBACK == nfvi_action_type:
|
||||
if nfvi.objects.v1.INSTANCE_ACTION_TYPE.LIVE_MIGRATE_ROLLBACK \
|
||||
== nfvi_action_type:
|
||||
self._action_data.nfvi_action_data_change(nfvi_action_type,
|
||||
nfvi_action_state, reason)
|
||||
self._persist()
|
||||
self._nfvi_instance_handle_action_change()
|
||||
return
|
||||
|
||||
elif nfvi.objects.v1.INSTANCE_ACTION_TYPE.RESIZE == nfvi_action_type:
|
||||
if INSTANCE_ACTION_TYPE.REVERT_RESIZE \
|
||||
== self._action_data.action_type:
|
||||
nfvi_action_type \
|
||||
= nfvi.objects.v1.INSTANCE_ACTION_TYPE.REVERT_RESIZE
|
||||
self._action_data.nfvi_action_data_change(
|
||||
nfvi_action_type, nfvi_action_state, reason)
|
||||
self._persist()
|
||||
self._nfvi_instance_handle_action_change()
|
||||
return
|
||||
|
||||
if not self.guest_services.are_provisioned():
|
||||
return
|
||||
|
||||
@ -2835,11 +2879,6 @@ class Instance(ObjectData):
|
||||
nfvi_action_type \
|
||||
= nfvi.objects.v1.INSTANCE_ACTION_TYPE.CONFIRM_RESIZE
|
||||
|
||||
elif INSTANCE_ACTION_TYPE.REVERT_RESIZE \
|
||||
== self._action_data.action_type:
|
||||
nfvi_action_type \
|
||||
= nfvi.objects.v1.INSTANCE_ACTION_TYPE.REVERT_RESIZE
|
||||
|
||||
self._action_data.nfvi_action_data_change(nfvi_action_type,
|
||||
nfvi_action_state, reason)
|
||||
self._persist()
|
||||
|
Loading…
x
Reference in New Issue
Block a user