Merge "Add extra safety to metastatic bnr cleanup"

This commit is contained in:
Zuul 2024-08-28 21:05:06 +00:00 committed by Gerrit Code Review
commit 1c3cd06e99

View File

@ -321,10 +321,18 @@ class MetastaticAdapter(statemachine.Adapter):
self.log.info("Backing node %s has been idle for "
"%s seconds, releasing",
bnr.node_id, now - bnr.last_used)
# Set the bnr to failed just in case something
# goes wrong after this point, we won't use it
# any more.
bnr.failed = True
node = self._getNode(bnr.node_id)
node.state = zk.USED
self.zk.storeNode(node)
self.zk.forceUnlockNode(node)
if node:
# In case the node was already removed due
# to an error, allow the bnr to still be
# cleaned up.
node.state = zk.USED
self.zk.storeNode(node)
self.zk.forceUnlockNode(node)
backing_node_records.remove(bnr)
return []