Francesco Romani has uploaded a new change for review.
Change subject: migration: build new reason on success ......................................................................
migration: build new reason on success
There is no need to cache successfull responses, it is cleaner and safer to build them on the fly when requested.
We should only cache errors, and only because SourceThread is orchestrating DowntimeThread and MonitorThread.
Change-Id: Ic42b70be6f5a5406e23916e16a678dd8caf0f500 Signed-off-by: Francesco Romani fromani@redhat.com --- M vdsm/virt/migration.py 1 file changed, 30 insertions(+), 10 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/00/42800/1
diff --git a/vdsm/virt/migration.py b/vdsm/virt/migration.py index 8cdfc10..0e6a024 100644 --- a/vdsm/virt/migration.py +++ b/vdsm/virt/migration.py @@ -53,6 +53,20 @@ VIR_MIGRATE_PARAM_GRAPHICS_URI = 'graphics_uri'
+class MigrationStatus(object): + IN_PROGRESS = 'Migration in progress' + COMPLETED = 'Migration done' + SAVESTATE_DONE = 'SaveState done' + CANCELED = 'Migration process cancelled' + + +class MigrationAbortReason(object): + UNKNOWN = 0, # no further detail available. + CLIENT = 1 + MAX_TIME = 2 + STALLED = 3 + + class SourceThread(threading.Thread): """ A thread that takes care of migration on the source vdsm. @@ -90,10 +104,7 @@ self._autoConverge = autoConverge self._compressed = compressed self._last_error = None - self._last_status = { - 'status': { - 'code': 0, - 'message': 'Migration in progress'}} + self._last_status = MigrationStatus.IN_PROGRESS self._progress = 0 threading.Thread.__init__(self) self._preparingMigrationEvt = True @@ -107,13 +118,23 @@ def getStat(self): """ Get the status of the migration. + + TODO: this method is troublesome. We are *lying*, we + are *not* compliant to the schema and we know it. + The problem is that we cannot change the return value + to conform to schema and to cleanup things, for + legacy constraings. """
if self._last_error is None: - res = utils.picklecopy(self._last_status) + res = response.success(message=self._last_status)
self._updateStatus()
+ # this uglyness is REQUIRED_FOR: Engine 3.x + # TODO when we can break compatibility: + # refactor and cleanup. Schema is already + # much better, too bad we cannot comply. return self._addMigrationFields(res) else: return utils.picklecopy(self._last_error) @@ -232,7 +253,7 @@ self._progress = 100 if not self.hibernating: self._vm.setDownStatus(NORMAL, vmexitreason.MIGRATION_SUCCEEDED) - self._last_status['status']['message'] = 'Migration done' + self._last_status = MigrationStatus.COMPLETED else: # don't pickle transient params for ignoreParam in ('displayIp', 'display', 'pid'): @@ -247,7 +268,7 @@ self._vm.cif.teardownVolumePath(self._dstparams)
self._vm.setDownStatus(NORMAL, vmexitreason.SAVE_STATE_SUCCEEDED) - self._last_status['status']['message'] = 'SaveState done' + self._last_status = MigrationStatus.SAVESTATE_DONE
def _patchConfigForLegacy(self): """ @@ -421,9 +442,8 @@ if not self._preparingMigrationEvt: raise else: - self._last_status['status']['message'] = \ - 'Migration process cancelled' - return self._last_status + self._last_status = MigrationStatus.CANCELED + return response.success(message=self._last_status)
def exponential_downtime(downtime, steps):
automation@ovirt.org has posted comments on this change.
Change subject: migration: build new reason on success ......................................................................
Patch Set 1:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: migration: build new reason on success ......................................................................
Patch Set 2:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: migration: build new reason on success ......................................................................
Patch Set 3:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: migration: build new reason on success ......................................................................
Patch Set 4:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: migration: build new reason on success ......................................................................
Patch Set 5:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: migration: build new reason on success ......................................................................
Patch Set 6:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: migration: build new reason on success ......................................................................
Patch Set 7:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
vdsm-patches@lists.fedorahosted.org