From aba9b4e1349318839364d278f094b20f57083251 Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Thu, 27 Feb 2020 17:31:49 -0500 Subject: [PATCH] Fix for clearing assigned nodes that have vanished If a node request disappears, we are assuming the node znodes that have been assigned to it are still around, but it turns out they may not be for strange, odd reasons. Attempting to store to them will cause errors. We need to handle that. Change-Id: I10dbce96e4d789a0d1d8d82d72a780fb63b66d62 --- nodepool/driver/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nodepool/driver/__init__.py b/nodepool/driver/__init__.py index 429f2cdbc..0975bddf3 100644 --- a/nodepool/driver/__init__.py +++ b/nodepool/driver/__init__.py @@ -601,7 +601,10 @@ class NodeRequestHandler(NodeRequestHandlerNotifications, if clear_allocation: node.allocated_to = None - self.zk.storeNode(node) + try: + self.zk.storeNode(node) + except Exception: + self.log.exception("Error clearing node allocation:") try: self.zk.unlockNode(node) @@ -674,10 +677,7 @@ class NodeRequestHandler(NodeRequestHandlerNotifications, # requests can use them. if not self.zk.getNodeRequest(self.request.id): self.log.info("Node request disappeared") - for node in self.nodeset: - node.allocated_to = None - self.zk.storeNode(node) - self.unlockNodeSet() + self.unlockNodeSet(clear_allocation=True) try: self.zk.unlockNodeRequest(self.request) except exceptions.ZKLockException: