Nir Soffer has uploaded a new change for review.
Change subject: vm: Cleanup waiting for xml update ......................................................................
vm: Cleanup waiting for xml update
This patch cleans up a bit the code for waiting until libvirt xml is updated after pivot was completed.
- Clarify confusing log message claiming that pivot failed after it completed successfully - Cleanup creation of volumes lists using generator expression - More clear logic for checking current volumes list - Replace detailed log message and unhelpful exception with detailed exception - Move comment out of the loop to make the loop more clear - Remove unneeded keys() calls when looking up alias in chains
This code was added as temporary solution until libvirt is fixed, but I think we would like keep a simplified version of it even after libvirt is fixed, verifying that the operation was successful.
Change-Id: I9fec5416a62736bad461ddd0b54093d23960b7a6 Signed-off-by: Nir Soffer nsoffer@redhat.com --- M vdsm/virt/vm.py 1 file changed, 27 insertions(+), 24 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/38/39938/1
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py index efadbdb..8ece47b 100644 --- a/vdsm/virt/vm.py +++ b/vdsm/virt/vm.py @@ -5100,40 +5100,43 @@ # synchronized and we may start the vm with a stale volume in the # future. See https://bugzilla.redhat.com/show_bug.cgi?id=1202719 for # more details. - # TODO: Remove once we depend on a libvirt with this bug fixed.
# We expect libvirt to show that the original leaf has been removed # from the active volume chain. origVols = sorted([x['volumeID'] for x in self.drive.volumeChain]) - expectedVols = origVols[:] - expectedVols.remove(self.drive.volumeID) + expectedVols = [v for v in origVols if v != self.driveVolumeID]
alias = self.drive['alias'] self.vm.log.info("Waiting for libvirt to update the XML after pivot " "of drive %s completed", alias) - while True: - # This operation should complete in either one or two iterations of - # this loop. Until libvirt updates the XML there is nothing to do - # but wait. While we wait we continue to tell engine that the job - # is ongoing. If we are still in this loop when the VM is powered - # off, the merge will be resolved manually by engine using the - # reconcileVolumeChain verb. - chains = self.vm._driveGetActualVolumeChain([self.drive]) - if alias not in chains.keys(): - raise RuntimeError("Failed to retrieve volume chain for " - "drive %s. Pivot failed.", alias) - curVols = sorted([entry.uuid for entry in chains[alias]])
- if curVols == origVols: - time.sleep(1) - elif curVols == expectedVols: + # This operation should complete in either one or two iterations of + # this loop. Until libvirt updates the XML there is nothing to do + # but wait. While we wait we continue to tell engine that the job + # is ongoing. If we are still in this loop when the VM is powered + # off, the merge will be resolved manually by engine using the + # reconcileVolumeChain verb. + # TODO: Check once when we depend on a libvirt with this bug fixed. + + while True: + chains = self.vm._driveGetActualVolumeChain([self.drive]) + if alias not in chains: + raise RuntimeError("Failed to retrieve volume chain for " + "drive %s after pivot completed", alias) + + curVols = sorted(entry.uuid for entry in chains[alias]) + + if curVols == expectedVols: self.vm.log.info("The XML update has been completed") - break - else: - self.log.error("Bad volume chain found for drive %s. Previous " - "chain: %s, Expected chain: %s, Actual chain: " - "%s", alias, origVols, expectedVols, curVols) - raise RuntimeError("Bad volume chain found") + return + + if curVols != origVols: + raise RuntimeError( + "Bad volume chain after pivot for drive %s. Previous " + "chain: %s, Expected chain: %s, Actual chain: %s" % + (alias, origVols, expectedVols, curVols)) + + time.sleep(1)
def _devicesWithAlias(domXML):
automation@ovirt.org has posted comments on this change.
Change subject: vm: Cleanup waiting for xml update ......................................................................
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'])
oVirt Jenkins CI Server has posted comments on this change.
Change subject: vm: Cleanup waiting for xml update ......................................................................
Patch Set 1:
Build Started (1/2) -> http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/17755/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: vm: Cleanup waiting for xml update ......................................................................
Patch Set 1:
Build Started (2/2) -> http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/17926/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: vm: Cleanup waiting for xml update ......................................................................
Patch Set 1:
Build Successful
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/17926/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/17755/ : SUCCESS
Jenkins CI RO has abandoned this change.
Change subject: vm: Cleanup waiting for xml update ......................................................................
Abandoned
Abandoned due to no activity - please restore if still relevant
gerrit-hooks has posted comments on this change.
Change subject: vm: Cleanup waiting for xml update ......................................................................
Patch Set 1:
* Update tracker: IGNORE, no Bug-Url found
Nir Soffer has restored this change.
Change subject: vm: Cleanup waiting for xml update ......................................................................
Restored
vdsm-patches@lists.fedorahosted.org