Add debug info for deploy/delete/resize

To make debug process conveniently , add more debug logs into
deploy/delete/resize methods , at the top of method and at the
end of the method , to make the process clearly , and print exception
stacktrace if necessary.

The log info should be like this :
1. Enter to $method instance of $instance_uuid
2. Exit to $method instance of $instance_uuid

Change-Id: I6678976c09ba923a0ada68a37a706642c18ed0f0
This commit is contained in:
Zhao_Jian 2014-11-06 14:16:07 +08:00
parent 64139a45b7
commit 13085fefd5
4 changed files with 46 additions and 12 deletions

View File

@ -610,10 +610,13 @@ class PowerVCCloudManager(manager.Manager):
:param force_delete: If True, the instance will be deleted even if the :param force_delete: If True, the instance will be deleted even if the
task state is set to 'deleting'. task state is set to 'deleting'.
""" """
LOG.debug(_('Enter to unregister instance of %s .') % local_instance)
# If the instance does not exist then ignore # If the instance does not exist then ignore
if not local_instance: if not local_instance:
LOG.debug(_('Instance does not exist locally')) LOG.debug(_('Instance does not exist locally'))
LOG.debug(_('Exit to unregister instance of %s .')
% local_instance)
return return
instance_ref = local_instance instance_ref = local_instance
@ -628,6 +631,9 @@ class PowerVCCloudManager(manager.Manager):
{'task_state': task_states.DELETING, 'progress': 0}) {'task_state': task_states.DELETING, 'progress': 0})
notifications.send_update(ctx, old_ref, instance_ref, notifications.send_update(ctx, old_ref, instance_ref,
service='powervc') service='powervc')
LOG.debug(_("Sent a notification for the updated state of %s,"
"event type is %s")
% (instance_ref.get('uuid'), 'powervc'))
# Delete the instance from the local database # Delete the instance from the local database
try: try:
@ -650,6 +656,11 @@ class PowerVCCloudManager(manager.Manager):
compute.utils.notify_about_instance_usage( compute.utils.notify_about_instance_usage(
self.notifier, ctx, instance_ref, 'delete.sync', network_info={}, self.notifier, ctx, instance_ref, 'delete.sync', network_info={},
system_metadata={}, extra_usage_info={}) system_metadata={}, extra_usage_info={})
LOG.debug(_('Send a notification about instance deletion of %s,'
'event type is %s')
% (instance_ref.get('uuid'), 'delete.sync'))
LOG.debug(_('Exit to unregister instance of %s .')
% local_instance.get('uuid'))
def _is_pvc_instance(self, ctx, local_instance): def _is_pvc_instance(self, ctx, local_instance):
""" """
@ -1537,6 +1548,9 @@ class PowerVCCloudManager(manager.Manager):
"""Remove the local instance if it's not performing a task and """Remove the local instance if it's not performing a task and
its vm_state is not BUILDING|DELETED|SOFT_DELETED|DELETING(force). its vm_state is not BUILDING|DELETED|SOFT_DELETED|DELETING(force).
""" """
LOG.debug(_('Enter to remove local instance of %s')
% local_instance.get('uuid'))
local_task_state = local_instance.get('task_state') local_task_state = local_instance.get('task_state')
local_vm_state = local_instance.get('vm_state') local_vm_state = local_instance.get('vm_state')
LOG.debug(_('Remove local instance %(ins)s, vm_state: %(vm)s, ' LOG.debug(_('Remove local instance %(ins)s, vm_state: %(vm)s, '
@ -1562,6 +1576,8 @@ class PowerVCCloudManager(manager.Manager):
local_vm_state != vm_states.BUILDING local_vm_state != vm_states.BUILDING
): ):
self._unregister_instance(context, local_instance) self._unregister_instance(context, local_instance)
LOG.debug(_('Exit to remove local instance of %s')
% local_instance.get('uuid'))
return True return True
LOG.debug(_('Skip remove local_instance %(ins)s from local DB, because' LOG.debug(_('Skip remove local_instance %(ins)s from local DB, because'
@ -1773,8 +1789,8 @@ class PowerVCCloudManager(manager.Manager):
count_updated_instances += 1 count_updated_instances += 1
except Exception, e: except Exception, e:
count_errors += 1 count_errors += 1
LOG.error(_("_periodic_instance_sync pvc to local: ") + str(e)) LOG.exception(_("_periodic_instance_sync pvc to local: %s")
% e)
# Sync. from local nova DB to PowerVC, to remove invalid instances # Sync. from local nova DB to PowerVC, to remove invalid instances
# that are not in PowerVC anymore. This only happens during a full # that are not in PowerVC anymore. This only happens during a full
# sync of all instances. # sync of all instances.
@ -1791,8 +1807,8 @@ class PowerVCCloudManager(manager.Manager):
count_deleted_instances += 1 count_deleted_instances += 1
except Exception, e: except Exception, e:
count_errors += 1 count_errors += 1
LOG.error(_("_periodic_instance_sync local to pvc: " + str(e))) LOG.exception(_("_periodic_instance_sync local to pvc: %s")
% e)
LOG.info(_(""" LOG.info(_("""
******************************* *******************************
Instance sync. is complete. Instance sync. is complete.

View File

@ -231,8 +231,7 @@ class PowerVCDriver(driver.ComputeDriver):
:param block_device_info: Information about block devices to be :param block_device_info: Information about block devices to be
attached to the instance. attached to the instance.
""" """
LOG.info(_("Deploying instance %(uuid)s") % instance) LOG.info(_("Begin to deploy the instance %(uuid)s") % instance)
# get PowerVC Image id # get PowerVC Image id
pvcimage = self._get_pvc_image_uuid(image_meta) pvcimage = self._get_pvc_image_uuid(image_meta)
@ -285,8 +284,8 @@ class PowerVCDriver(driver.ComputeDriver):
self._clean_vm_and_save_fault_message(e, e.message, self._clean_vm_and_save_fault_message(e, e.message,
context, instance) context, instance)
LOG.debug("Succeeded to created instance to spawn: %s" % createdServer) LOG.info("Finish to create the instance to spawn: %s successfully"
% createdServer)
return createdServer return createdServer
def _clean_vm_and_save_fault_message(self, exp, message, context, def _clean_vm_and_save_fault_message(self, exp, message, context,
@ -345,7 +344,10 @@ class PowerVCDriver(driver.ComputeDriver):
:param destroy_disks: Indicates if disks should be destroyed :param destroy_disks: Indicates if disks should be destroyed
""" """
return self._service.destroy(instance) LOG.debug(_("Enter to destroy instance of %(uuid)s") % instance)
responseValue = self._service.destroy(instance)
LOG.debug(_("Exit to destroy instance of %(uuid)s") % instance)
return responseValue
def reboot(self, context, instance, network_info, reboot_type, def reboot(self, context, instance, network_info, reboot_type,
block_device_info=None, bad_volumes_callback=None): block_device_info=None, bad_volumes_callback=None):
@ -563,6 +565,7 @@ class PowerVCDriver(driver.ComputeDriver):
:param power_on: True if the instance should be powered on, False :param power_on: True if the instance should be powered on, False
otherwise otherwise
""" """
LOG.debug(_("Enter to resize instance of %(uuid)s") % instance)
returnvalue = False returnvalue = False
if resize_instance: if resize_instance:
@ -585,7 +588,7 @@ class PowerVCDriver(driver.ComputeDriver):
start the instance directly. start the instance directly.
Based on the above reason, remove the 'power-on' operation. Based on the above reason, remove the 'power-on' operation.
""" """
LOG.debug(_("Exit to resize instance of %(uuid)s") % instance)
return returnvalue return returnvalue
def confirm_migration(self, migration, instance, network_info): def confirm_migration(self, migration, instance, network_info):

View File

@ -674,6 +674,8 @@ class PowerVCService(object):
userdata = instance.user_data # already base64 encoded by local OS userdata = instance.user_data # already base64 encoded by local OS
if not isDefer: if not isDefer:
LOG.debug(_('Enter to invoke powervc api to deploy instance'
'of %s, isDefer status is %s') % (name, isDefer))
createdServer = \ createdServer = \
self._manager.create(name=name, self._manager.create(name=name,
image=imageUUID, image=imageUUID,
@ -688,7 +690,11 @@ class PowerVCService(object):
nics=nics, nics=nics,
hypervisor=hypervisorID, hypervisor=hypervisorID,
availability_zone=availability_zone) availability_zone=availability_zone)
LOG.debug(_('Exit to invoke powervc api to deploy instance of %s,'
'isDefer status is %s') % (name, isDefer))
else: else:
LOG.debug(_('Enter to invoke powervc api to deploy instance of %s,'
'isDefer status is %s') % (name, isDefer))
createdServer = self._manager.create(name=name, createdServer = self._manager.create(name=name,
image=imageUUID, image=imageUUID,
flavor=flavorDict, flavor=flavorDict,
@ -701,6 +707,8 @@ class PowerVCService(object):
# key_data = key_data, # key_data = key_data,
config_drive=config_drive, config_drive=config_drive,
nics=nics) nics=nics)
LOG.debug(_('Exit to invoke powervc api to deploy instance of %s,'
'isDefer status is %s') % (name, isDefer))
LOG.debug(_('Created Server: %s' % createdServer)) LOG.debug(_('Created Server: %s' % createdServer))
LOG.debug(_( LOG.debug(_(
@ -813,7 +821,11 @@ class PowerVCService(object):
% server_instance.id) % server_instance.id)
return True return True
LOG.debug(_("Enter to invoke powervc api to delete instance of %s")
% server)
delete_response = self._manager.delete(server) delete_response = self._manager.delete(server)
LOG.debug(_("Exit to invoke powervc api to delete instance of %s")
% server)
self._validate_response(delete_response) self._validate_response(delete_response)
@ -930,8 +942,11 @@ class PowerVCService(object):
:para body: the body of rest request :para body: the body of rest request
""" """
LOG.debug(_("Enter to invoke powervc api to resize instance of %s")
% server.id)
response = self._manager._resize_pvc(server, props) response = self._manager._resize_pvc(server, props)
LOG.debug(_("Exit to invoke powervc api to resize instance of %s")
% server.id)
return response return response
def resize_instance(self, context, migration, instance, def resize_instance(self, context, migration, instance,

View File

@ -370,7 +370,7 @@ class PowerVCDriverTestCase(test.NoDBTestCase):
pvc_driver._service.update_correct_host = MagicMock() pvc_driver._service.update_correct_host = MagicMock()
context = 0 context = 0
migration = 0 migration = 0
instance = 0 instance = {'uuid': '582124fc-2ebb-441c-8418-c742078d2738'}
disk_info = 0 disk_info = 0
network_info = 0 network_info = 0
image_meta = 0 image_meta = 0