From d722b62b975e0ce143c259a4a3efb45fdcf49870 Mon Sep 17 00:00:00 2001 From: licanwei Date: Mon, 16 Oct 2017 00:55:55 -0700 Subject: [PATCH] Optimize check_migrated in cinder_helper.py There are more than one 'migrating' status in the volume migration. Others include starting, completing and so on. So we should check the final status 'success' and 'error'. Change-Id: I8ee9330aa32ec4516f2bf9e046ea68a72bc8a53d --- watcher/common/cinder_helper.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/watcher/common/cinder_helper.py b/watcher/common/cinder_helper.py index 0ee1ad3c3..f43207a05 100644 --- a/watcher/common/cinder_helper.py +++ b/watcher/common/cinder_helper.py @@ -165,7 +165,8 @@ class CinderHelper(object): def check_migrated(self, volume, retry_interval=10): volume = self.get_volume(volume) - while getattr(volume, 'migration_status') == 'migrating': + final_status = ('success', 'error') + while getattr(volume, 'migration_status') not in final_status: volume = self.get_volume(volume.id) LOG.debug('Waiting the migration of {0}'.format(volume)) time.sleep(retry_interval)