Merge "Provide some accounting of node usage in logs"

This commit is contained in:
Zuul 2018-10-16 16:17:49 +00:00 committed by Gerrit Code Review
commit 081b715283
4 changed files with 14 additions and 4 deletions

View File

@ -396,7 +396,7 @@ class PipelineManager(object):
if not was_running:
nodeset = build.build_set.getJobNodeSet(build.job.name)
self.sched.nodepool.returnNodeSet(nodeset)
self.sched.nodepool.returnNodeSet(nodeset, build)
build.result = 'CANCELED'
canceled = True
canceled_jobs.add(build.job.name)

View File

@ -679,7 +679,7 @@ class NodeSet(ConfigObject):
name = self.name + ' '
else:
name = ''
return '<NodeSet %s%s%s>' % (name, self.nodes, self.groups)
return '<NodeSet %s%s>' % (name, list(self.nodes.values()))
def __len__(self):
return len(self.nodes)

View File

@ -120,8 +120,18 @@ class Nodepool(object):
node.state = model.STATE_IN_USE
self.sched.zk.storeNode(node)
def returnNodeSet(self, nodeset):
def returnNodeSet(self, nodeset, build=None):
self.log.info("Returning nodeset %s" % (nodeset,))
if (build and build.start_time and build.end_time and
build.build_set and build.build_set.item and
build.build_set.item.change and
build.build_set.item.change.project):
duration = build.end_time - build.start_time
project = build.build_set.item.change.project
self.log.info("Nodeset %s with %s nodes was in use "
"for %s seconds for build %s for project %s",
nodeset, len(nodeset.nodes), duration, build,
project)
for node in nodeset.getNodes():
if node.lock is None:
self.log.error("Node %s is not locked" % (node,))

View File

@ -1218,7 +1218,7 @@ class Scheduler(threading.Thread):
except Exception:
self.log.exception("Unable to process autohold for %s" % build)
try:
self.nodepool.returnNodeSet(build.nodeset)
self.nodepool.returnNodeSet(build.nodeset, build)
except Exception:
self.log.exception("Unable to return nodeset %s" % build.nodeset)