Provide some accounting of node usage in logs

It would be good to provide this information in other ways (e.g.,
statsd, SQL), but for now, try to at least emit some useful accounting
information that can be collected from logs.

Change-Id: Ic12d91940bdd4b5a81596627d7544015df5eba09
This commit is contained in:
James E. Blair 2018-09-27 12:50:15 -07:00 committed by Clark Boylan
parent 824ca389b8
commit f080776c1d
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)