From eda85cc624988428148401f12a2dde6a509dcb1e Mon Sep 17 00:00:00 2001 From: jichenjc Date: Thu, 8 Feb 2018 17:12:28 +0800 Subject: [PATCH] Add log for snapshot an instance some drivers are interested in the snapshot performance so provide a generic info about the time spent in doing snapshot will be helpful to admin and developer. Change-Id: I467a991c3da7be86640a1fae5686ef5e9e897cf5 --- nova/compute/manager.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 87a254f6b3..01ba6796a8 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -3342,8 +3342,11 @@ class ComputeManager(manager.Manager): instance.task_state = task_state instance.save(expected_task_state=expected_state) - self.driver.snapshot(context, instance, image_id, - update_task_state) + with timeutils.StopWatch() as timer: + self.driver.snapshot(context, instance, image_id, + update_task_state) + LOG.info('Took %0.2f seconds to snapshot the instance on ' + 'the hypervisor.', timer.elapsed(), instance=instance) instance.task_state = None instance.save(expected_task_state=task_states.IMAGE_UPLOADING)