Merge "Return nodes after use" into feature/zuulv3

changes/88/422288/4
Jenkins 6 years ago committed by Gerrit Code Review
commit 932f49b7f9

@ -83,6 +83,12 @@ class TestNodepool(BaseTestCase):
for node in nodeset.getNodes():
self.assertEqual(node.state, 'in-use')
# Return the nodes
self.nodepool.returnNodeset(nodeset)
for node in nodeset.getNodes():
self.assertIsNone(node.lock)
self.assertEqual(node.state, 'used')
def test_node_request_disconnect(self):
# Test that node requests are re-submitted after disconnect

@ -599,6 +599,13 @@ class PipelineManager(object):
self.sched.mutex.release(item, build.job)
self.log.debug("Item %s status is now:\n %s" %
(item, item.formatStatus()))
try:
nodeset = build.build_set.getJobNodeSet(build.job.name)
self.nodepool.returnNodeset(nodeset)
except Exception:
self.log.exception("Unable to return nodeset %s" % (nodeset,))
return True
def onMergeCompleted(self, event):

@ -45,8 +45,14 @@ class Nodepool(object):
node.state = 'in-use'
self.sched.zk.storeNode(node)
def returnNodes(self, nodes, used=True):
pass
def returnNodeset(self, nodeset):
for node in nodeset.getNodes():
if node.lock is None:
raise Exception("Node %s is not locked" % (node,))
if node.state == 'in-use':
node.state = 'used'
self.sched.zk.storeNode(node)
self._unlockNodes(nodeset.getNodes())
def unlockNodeset(self, nodeset):
self._unlockNodes(nodeset.getNodes())

@ -810,12 +810,13 @@ class Scheduler(threading.Thread):
if build_set is not build_set.item.current_build_set:
self.log.warning("Build set %s is not current" % (build_set,))
self.nodepool.returnNodes(request.nodes, used=False)
self.nodepool.returnNodeset(request.nodeset)
return
pipeline = build_set.item.pipeline
if not pipeline:
self.log.warning("Build set %s is not associated with a pipeline" %
(build_set,))
self.nodepool.returnNodeset(request.nodeset)
return
pipeline.manager.onNodesProvisioned(event)

Loading…
Cancel
Save