From 8ca9bbef7dd358e7da65a4f4cf61db724f18a18f Mon Sep 17 00:00:00 2001 From: Fermi Perumal Date: Wed, 11 May 2022 12:40:01 -0700 Subject: [PATCH 1/2] Add error handling for host allocation failures Add logic to catch allocation errors while moving hosts and fail gracefully Related HD ticket: http://rails.spimageworks.com/helpdesk/tickets/423339 --- cuegui/cuegui/MenuActions.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/cuegui/cuegui/MenuActions.py b/cuegui/cuegui/MenuActions.py index 058ea2a39..58a520c0e 100644 --- a/cuegui/cuegui/MenuActions.py +++ b/cuegui/cuegui/MenuActions.py @@ -1565,10 +1565,26 @@ def changeAllocation(self, rpcObjects=None): self._caller, title, body, sorted(allocations.keys()), 0, False) if choice: allocation = allocations[str(allocationName)] + error_hosts = [] for host in hosts: - self.cuebotCall(host.setAllocation, - "Set Allocation on %s Failed" % host.data.name, - allocation) + try: + self.cuebotCall(host.setAllocation, + "Set Allocation on %s Failed" % host.data.name, + allocation) + except Exception as e: + # Handle allocation modification errors separately + if (hasattr(e, "details") and + "EntityModificationError" in str(e.details())): + error_hosts.append(host.name()) + else: + raise + if len(error_hosts): + error_msg = "{hosts} not moved.\nHosts with reserved cores " \ + "cannot be moved between allocations." + QtWidgets.QMessageBox.warning(self._caller, + "Warning", + error_msg.format(hosts=", ".join(error_hosts)), + QtWidgets.QMessageBox.Ok) self._update() setRepair_info = ["Set Repair State", None, "configure"] From 63550e4aa5b60214107df95c3d03fa4828d12152 Mon Sep 17 00:00:00 2001 From: Fermi Perumal Date: Thu, 12 May 2022 12:05:57 -0700 Subject: [PATCH 2/2] Fix pylint errors --- cuegui/cuegui/MenuActions.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cuegui/cuegui/MenuActions.py b/cuegui/cuegui/MenuActions.py index 58a520c0e..ff4d2b34d 100644 --- a/cuegui/cuegui/MenuActions.py +++ b/cuegui/cuegui/MenuActions.py @@ -1567,18 +1567,20 @@ def changeAllocation(self, rpcObjects=None): allocation = allocations[str(allocationName)] error_hosts = [] for host in hosts: + # pylint: disable=broad-except try: self.cuebotCall(host.setAllocation, - "Set Allocation on %s Failed" % host.data.name, - allocation) + "Set Allocation on %s Failed" % host.data.name, + allocation) except Exception as e: # Handle allocation modification errors separately - if (hasattr(e, "details") and + # pylint: disable=no-member + if (hasattr(e, "details") and "EntityModificationError" in str(e.details())): error_hosts.append(host.name()) else: raise - if len(error_hosts): + if error_hosts: error_msg = "{hosts} not moved.\nHosts with reserved cores " \ "cannot be moved between allocations." QtWidgets.QMessageBox.warning(self._caller,