Vinzenz Feenstra has uploaded a new change for review.
Change subject: vdsm: Replaced all too generic except: handlers ......................................................................
vdsm: Replaced all too generic except: handlers
Change-Id: I00f1c6650b357cebfcaa375a2babb8c12637fd5a Signed-off-by: Vinzenz Feenstra vfeenstr@redhat.com --- M vdsm/vm.py 1 file changed, 34 insertions(+), 34 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/40/17740/1
diff --git a/vdsm/vm.py b/vdsm/vm.py index 0b71314..79e13a9 100644 --- a/vdsm/vm.py +++ b/vdsm/vm.py @@ -184,7 +184,7 @@ if not status['status']['code']: self.log.error("Machine already exists on the destination") self.status = errCode['exist'] - except: + except Exception: self.log.error("Error initiating connection", exc_info=True) self.status = errCode['noConPeer']
@@ -243,7 +243,7 @@ if self._mode != 'file': try: self.destServer.destroy(self._vm.id) - except: + except Exception: self.log.error("Failed to destroy remote VM", exc_info=True) # if the guest was stopped before migration, we need to cont it if self._mode == 'file' or self._method != 'online': @@ -332,7 +332,7 @@ self._vm._dom.save(fname) finally: self._vm.cif.teardownVolumePath(self._dst) - except: + except Exception: self._vm._vmStats.cont() raise else: @@ -1393,7 +1393,7 @@ if self._blockDev is None: try: self._blockDev = utils.isBlockDevice(self.path) - except: + except Exception: self.log.debug("Unable to determine if the path '%s' is a " "block device", self.path, exc_info=True) return self._blockDev @@ -2048,7 +2048,7 @@ try: with self._confLock: del self.conf['pauseCode'] - except: + except KeyError: pass
if 'recover' in self.conf: @@ -2119,7 +2119,7 @@ self._saveStateInternal() try: self._getUnderlyingVmInfo() - except: + except Exception: # we do not care if _dom suddenly died now pass
@@ -2164,7 +2164,7 @@ if self.conf.get('volatileFloppy'): self._ejectFloppy() self.log.debug('ejected volatileFloppy') - except: + except Exception: self.log.error("Reboot event failed", exc_info=True)
def onShutdown(self): @@ -2332,7 +2332,7 @@ try: with self._confLock: del self.conf['pauseCode'] - except: + except KeyError: pass return {'status': doneCode, 'output': ['']} finally: @@ -2379,7 +2379,7 @@ 'code': errCode['exist']['status']['code'], 'message': 'VM without ACPI or active SolidICE tools. ' 'Try Forced Shutdown.'}} - except: + except Exception: self.log.error("Shutdown failed", exc_info=True) return {'status': {'code': errCode['exist']['status']['code'], 'message': 'Failed to shutdown VM. Try Forced Shutdown.'}} @@ -2395,7 +2395,7 @@ self.destroy() else: self._acpiShutdown() - except: + except Exception: self.log.error("_timedShutdown failed", exc_info=True)
def _cleanupDrives(self, *drives): @@ -2413,7 +2413,7 @@ for drive in drives: try: self.cif.teardownVolumePath(drive) - except: + except Exception: self.log.error("Drive teardown failure for %s", drive, exc_info=True)
@@ -2425,7 +2425,7 @@ try: self.log.debug("Floppy %s cleanup" % self.conf['floppy']) utils.rmFile(self.conf['floppy']) - except: + except Exception: pass
def _cleanupGuestAgent(self): @@ -2434,7 +2434,7 @@ """ try: self.guestAgent.stop() - except: + except Exception: pass
utils.rmFile(self._guestSocketFile) @@ -2454,11 +2454,11 @@ pass try: self.guestAgent.stop() - except: + except Exception: pass try: self._vmStats.stop() - except: + except Exception: pass self.saveState()
@@ -2523,7 +2523,7 @@ and decStats['statsAge'] > config.getint('vars', 'vm_command_timeout')): stats['monitorResponse'] = '-1' - except: + except Exception: self.log.error("Error fetching vm stats", exc_info=True) for var in decStats: if type(decStats[var]) is not dict: @@ -2536,7 +2536,7 @@ for value in decStats[var]: stats['disks'][var][value] = \ utils.convertToStr(decStats[var][value]) - except: + except Exception: self.log.error("Error setting vm disk stats", exc_info=True)
@@ -2560,7 +2560,7 @@ stats['pauseCode'] = self.conf['pauseCode'] try: stats.update(self.guestAgent.getGuestInfo()) - except: + except Exception: return stats memUsage = 0 realMemUsage = int(stats['memUsage']) @@ -2776,7 +2776,7 @@ # handle it. We must handle it now try: self._dom.destroy() - except: + except Exception: pass raise Exception('destroy() called before Vm started')
@@ -2819,7 +2819,7 @@
try: self._dom.setSchedulerParameters({'cpu_shares': cpuShares}) - except: + except Exception: self.log.warning('failed to set Vm niceness', exc_info=True)
def _run(self): @@ -3524,7 +3524,7 @@ for vmDevName, drive in newDrives.iteritems(): try: self.cif.teardownVolumePath(drive) - except: + except Exception: self.log.error("Unable to teardown drive: %s", vmDevName, exc_info=True)
@@ -3679,7 +3679,7 @@ for drive in newDrives.values(): # Update the drive information try: self.updateDriveParameters(drive) - except: + except Exception: # Here it's too late to fail, the switch already happened # and there's nothing we can do, we must to proceed anyway # to report the live snapshot success. @@ -3702,7 +3702,7 @@ try: self._dom.blockRebase(mergeStatus['path'], mergeStatus['basePath'], 0, 0) - except: + except Exception: mergeStatus['status'] = MERGESTATUS.FAILED self.log.error("Live merge failed for %s", mergeStatus['path'], exc_info=True) @@ -3718,7 +3718,7 @@
try: jobInfo = self._dom.blockJobInfo(mergeStatus['path'], 0) - except: + except Exception: jobInfo = None
if not jobInfo: @@ -3845,7 +3845,7 @@
try: self._setDiskReplica(srcDrive, dstDisk) - except: + except Exception: self.log.error("Unable to set the replication for disk '%s' with " "destination '%s'" % srcDrive.name, dstDisk) return errCode['replicaErr'] @@ -3865,12 +3865,12 @@ libvirt.VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT | libvirt.VIR_DOMAIN_BLOCK_REBASE_SHALLOW )) - except: + except Exception: self.log.error("Unable to start the replication for %s to %s", srcDrive.name, dstDiskCopy, exc_info=True) self.cif.teardownVolumePath(dstDiskCopy) raise - except: + except Exception: self.log.error("Cannot complete the disk replication process", exc_info=True) self._delDiskReplica(srcDrive) @@ -3878,7 +3878,7 @@
try: self.extendDriveVolume(srcDrive) - except: + except Exception: self.log.error("Initial extension request failed for %s", srcDrive.name, exc_info=True)
@@ -3938,12 +3938,12 @@ try: # Stopping the replication self._dom.blockJobAbort(srcDrive.name, blockJobFlags) - except: + except Exception: self.log.error("Unable to stop the replication for the drive: %s", srcDrive.name, exc_info=True) try: self.cif.teardownVolumePath(srcDrive.diskReplicate) - except: + except Exception: # There is nothing we can do at this point other than logging self.log.error("Unable to teardown the replication " "destination disk", exc_info=True) @@ -3951,7 +3951,7 @@ else: try: self.cif.teardownVolumePath(diskToTeardown) - except: + except Exception: # There is nothing we can do at this point other than logging self.log.error("Unable to teardown the previous chain: %s", diskToTeardown, exc_info=True) @@ -4044,7 +4044,7 @@ return self._diskSizeExtendCow(drive, newSizeBytes) else: return self._diskSizeExtendRaw(drive, newSizeBytes) - except: + except Exception: self.log.error("Unable to extend disk %s to size %s", drive.name, newSizeBytes, exc_info=True)
@@ -4094,7 +4094,7 @@ try: self._dom.updateDeviceFlags( diskelem.toxml(), libvirt.VIR_DOMAIN_DEVICE_MODIFY_FORCE) - except: + except Exception: self.log.debug("updateDeviceFlags failed", exc_info=True) self.cif.teardownVolumePath(drivespec) return {'status': {'code': errCode['changeDisk']['status']['code'], @@ -4178,7 +4178,7 @@ try: vmName = self.conf['vmName'].encode('utf-8') pid = supervdsm.getProxy().getVmPid(vmName) - except: + except Exception: pass return pid
oVirt Jenkins CI Server has posted comments on this change.
Change subject: vdsm: Replaced all too generic except: handlers in vm.py ......................................................................
Patch Set 1:
Build Successful
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/3759/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/3675/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/2868/ : SUCCESS
oVirt Jenkins CI Server has posted comments on this change.
Change subject: vdsm: Replaced all too generic except: handlers in vm.py ......................................................................
Patch Set 2:
Build Successful
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/3760/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/3676/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/2869/ : SUCCESS
Antoni Segura Puimedon has posted comments on this change.
Change subject: vdsm: Replaced all too generic except: handlers in vm.py ......................................................................
Patch Set 2: Code-Review+1
Owners of the methods should make sure that we do not need to catch baseExceptions, and comment otherwise.
oVirt Jenkins CI Server has posted comments on this change.
Change subject: vdsm: Replaced all too generic except: handlers in vm.py ......................................................................
Patch Set 3:
Build Successful
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/4739/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/4815/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/3930/ : SUCCESS
Dan Kenigsberg has posted comments on this change.
Change subject: vdsm: Replaced all too generic except: handlers in vm.py ......................................................................
Patch Set 3: Code-Review+2
Toni, I recall no reason to catch baseExceptions.
After this patch, the exceptions are still too generic... But let us take this as a first step.
Dan Kenigsberg has posted comments on this change.
Change subject: vdsm: Replaced all too generic except: handlers in vm.py ......................................................................
Patch Set 3:
Vinzenz, pleasw verify that migration still flies.
Dan Kenigsberg has posted comments on this change.
Change subject: vdsm: Replaced all too generic except: handlers in vm.py ......................................................................
Patch Set 4: Code-Review+2
Vinzenz Feenstra has posted comments on this change.
Change subject: vdsm: Replaced all too generic except: handlers in vm.py ......................................................................
Patch Set 5: Verified+1
oVirt Jenkins CI Server has posted comments on this change.
Change subject: vdsm: Replaced all too generic except: handlers in vm.py ......................................................................
Patch Set 5:
Build Successful
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/6605/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/5712/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/6518/ : SUCCESS
Dan Kenigsberg has posted comments on this change.
Change subject: vdsm: Replaced all too generic except: handlers in vm.py ......................................................................
Patch Set 5: Code-Review+2
Francesco Romani has posted comments on this change.
Change subject: vdsm: Replaced all too generic except: handlers in vm.py ......................................................................
Patch Set 5: Verified+1 Code-Review+1
looks good to me and it is also a step in the good direction.
Tested the following: * tests OK * virtTests OK * running VDSM machine got up OK * running VDM machine suspended and resumed OK
Dan Kenigsberg has submitted this change and it was merged.
Change subject: vdsm: Replaced all too generic except: handlers in vm.py ......................................................................
vdsm: Replaced all too generic except: handlers in vm.py
Change-Id: I00f1c6650b357cebfcaa375a2babb8c12637fd5a Signed-off-by: Vinzenz Feenstra vfeenstr@redhat.com Reviewed-on: http://gerrit.ovirt.org/17740 Reviewed-by: Dan Kenigsberg danken@redhat.com Reviewed-by: Francesco Romani fromani@redhat.com Tested-by: Francesco Romani fromani@redhat.com --- M vdsm/vm.py 1 file changed, 36 insertions(+), 36 deletions(-)
Approvals: Vinzenz Feenstra: Verified Dan Kenigsberg: Looks good to me, approved Francesco Romani: Verified; Looks good to me, but someone else must approve
vdsm-patches@lists.fedorahosted.org