Change in vdsm[master]: Live Merge: work around racy libvirt pivot
nsoffer at redhat.com
nsoffer at redhat.com
Tue Mar 31 19:44:53 UTC 2015
Nir Soffer has posted comments on this change.
Change subject: Live Merge: work around racy libvirt pivot
......................................................................
Patch Set 4: Code-Review+1
(7 comments)
The general solution looks correct, but the code can be more clear, and logging should be improved.
https://gerrit.ovirt.org/#/c/39303/4/vdsm/virt/vm.py
File vdsm/virt/vm.py:
Line 5126: # We expect libvirt to show that the original leaf has been removed
Line 5127: # from the active volume chain.
Line 5128: origVols = sorted([x['volumeID'] for x in self.drive.volumeChain])
Line 5129: expectedVols = origVols[:]
Line 5130: expectedVols.remove(self.drive.volumeID)
I think this would be little nicer then copying using slice and removing:
expectedVols = [v for v in origVols if v != self.driveVolumeID]
Line 5131:
Line 5132: alias = self.drive['alias']
Line 5133: self.vm.log.info("Waiting for libvirt to update the XML after pivot "
Line 5134: "of drive %s completed", alias)
Line 5137: # this loop. Until libvirt updates the XML there is nothing to do
Line 5138: # but wait. While we wait we continue to tell engine that the job
Line 5139: # is ongoing. If we are still in this loop when the VM is powered
Line 5140: # off, the merge will be resolved manually by engine using the
Line 5141: # reconcileVolumeChain verb.
Lets move the comment above this block, since it describe the whole loop, not a single step.
Line 5142: chains = self.vm._driveGetActualVolumeChain([self.drive])
Line 5143: if alias not in chains.keys():
Line 5144: raise RuntimeError("Failed to retrieve volume chain for "
Line 5145: "drive %s. Pivot failed.", alias)
Line 5141: # reconcileVolumeChain verb.
Line 5142: chains = self.vm._driveGetActualVolumeChain([self.drive])
Line 5143: if alias not in chains.keys():
Line 5144: raise RuntimeError("Failed to retrieve volume chain for "
Line 5145: "drive %s. Pivot failed.", alias)
Pivot failed? Pivot just completed successfully. This log is going to confuse many people.
Line 5146: curVols = sorted([entry.uuid for entry in chains[alias]])
Line 5147:
Line 5148: if curVols == origVols:
Line 5149: time.sleep(1)
Line 5142: chains = self.vm._driveGetActualVolumeChain([self.drive])
Line 5143: if alias not in chains.keys():
Line 5144: raise RuntimeError("Failed to retrieve volume chain for "
Line 5145: "drive %s. Pivot failed.", alias)
Line 5146: curVols = sorted([entry.uuid for entry in chains[alias]])
Please use generator expression
Line 5147:
Line 5148: if curVols == origVols:
Line 5149: time.sleep(1)
Line 5150: elif curVols == expectedVols:
Line 5147:
Line 5148: if curVols == origVols:
Line 5149: time.sleep(1)
Line 5150: elif curVols == expectedVols:
Line 5151: self.vm.log.info("The XML update has been completed")
Please add the drive info to the log.
Line 5152: break
Line 5153: else:
Line 5154: self.log.error("Bad volume chain found for drive %s. Previous "
Line 5155: "chain: %s, Expected chain: %s, Actual chain: "
Line 5152: break
Line 5153: else:
Line 5154: self.log.error("Bad volume chain found for drive %s. Previous "
Line 5155: "chain: %s, Expected chain: %s, Actual chain: "
Line 5156: "%s", alias, origVols, expectedVols, curVols)
Why log error when we raise? Lets raise an error with the message in this log - vdsm will log an exception for this error.
Current code has very clear error log, and then it will show very unclear exception with no info.
Line 5157: raise RuntimeError("Bad volume chain found")
Line 5158:
Line 5159:
Line 5160: def _devicesWithAlias(domXML):
Line 5153: else:
Line 5154: self.log.error("Bad volume chain found for drive %s. Previous "
Line 5155: "chain: %s, Expected chain: %s, Actual chain: "
Line 5156: "%s", alias, origVols, expectedVols, curVols)
Line 5157: raise RuntimeError("Bad volume chain found")
Lets make this block simpler, by separating the exit condition and the error. This make the normal flow (sleep) very clear.
if curVols == expectedVols:
log success
return
if curVols != origVols:
fail loudly
sleep
Line 5158:
Line 5159:
Line 5160: def _devicesWithAlias(domXML):
--
To view, visit https://gerrit.ovirt.org/39303
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I1e794622baf66c75cbe583be03a7b9a4a7e4883d
Gerrit-PatchSet: 4
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke at redhat.com>
Gerrit-Reviewer: Adam Litke <alitke at redhat.com>
Gerrit-Reviewer: Allon Mureinik <amureini at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Federico Simoncelli <fsimonce at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Greg Padgett <gpadgett at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: automation at ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
More information about the vdsm-patches
mailing list