From 45bc4c55acb9b025efe9acf9473fd6b33228061c Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Sun, 17 Jul 2016 00:11:00 -0400 Subject: [PATCH] Some summary logging from ridad. --- rida/builder.py | 4 ++++ rida/database.py | 10 +++++++--- rida/scheduler/main.py | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/rida/builder.py b/rida/builder.py index e0629201..791ab165 100644 --- a/rida/builder.py +++ b/rida/builder.py @@ -199,6 +199,10 @@ class KojiModuleBuilder(GenericBuilder): self.module_build_tag = "%s-build" % tag_name self.module_target = tag_name + def __repr__(self): + return "" % ( + self.module_str, self.module_tag) + def buildroot_resume(self): # XXX: experimental """ Resume existing buildroot. Sets __prep=True diff --git a/rida/database.py b/rida/database.py index 0a39ce80..12c71652 100644 --- a/rida/database.py +++ b/rida/database.py @@ -70,6 +70,8 @@ BUILD_STATES = { "ready": 5, } +INVERSE_BUILD_STATES = {v: k for k, v in BUILD_STATES.items()} + class RidaBase(object): # TODO -- we can implement functionality here common to all our model @@ -218,8 +220,9 @@ class ModuleBuild(Base): } def __repr__(self): - return "" % ( - self.name, self.version, self.release) + return "" % ( + self.name, self.version, self.release, + INVERSE_BUILD_STATES[self.state]) class ComponentBuild(Base): @@ -253,4 +256,5 @@ class ComponentBuild(Base): } def __repr__(self): - return "" % (self.package, self.module_id) + return "" % ( + self.package, self.module_id, self.state) diff --git a/rida/scheduler/main.py b/rida/scheduler/main.py index bcfce364..9cf54afd 100644 --- a/rida/scheduler/main.py +++ b/rida/scheduler/main.py @@ -32,6 +32,7 @@ proper scheduling component builds in the supported build systems. import inspect import logging +import operator import os import pprint import threading @@ -146,6 +147,8 @@ class Messaging(threading.Thread): class Polling(threading.Thread): def run(self): while True: + with rida.database.Database(config) as session: + self.log_summary(session) with rida.database.Database(config) as session: self.process_waiting_module_builds(session) with rida.database.Database(config) as session: @@ -155,6 +158,21 @@ class Polling(threading.Thread): log.info("Polling thread sleeping, %rs" % config.polling_interval) time.sleep(config.polling_interval) + def log_summary(self, session): + log.info("Current status:") + states = sorted(rida.BUILD_STATES.items(), key=operator.itemgetter(1)) + for name, code in states: + query = session.query(rida.database.ModuleBuild) + count = query.filter_by(state=code).count() + if count: + log.info(" * %i module builds in the %s state." % (count, name)) + if name == 'build': + for module_build in query.all(): + log.info(" * %r" % module_build) + for component_build in module_build.component_builds: + log.info(" * %r" % component_build) + + def process_waiting_module_builds(self, session): log.info("Looking for module builds stuck in the wait state.") builds = rida.database.ModuleBuild.by_state(session, "wait")