From ad4bcc846efa0698e01b879e959a587d56d72fdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0abata?= Date: Mon, 4 Jul 2016 17:17:43 +0200 Subject: [PATCH] Add the basic skeleton code for ridad and move some TODOs around MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Petr Šabata --- rida/builder.py | 8 ++++++ ridad.py | 66 +++++++++++++++++++++++++++++++------------------ 2 files changed, 50 insertions(+), 24 deletions(-) diff --git a/rida/builder.py b/rida/builder.py index e113a809..d58e0f98 100644 --- a/rida/builder.py +++ b/rida/builder.py @@ -24,3 +24,11 @@ # Written by Petr Šabata """Generic component build functions.""" + +# TODO: Create the relevant koji tags and targets. +# TODO: Query the PDC to find what modules satisfy the build dependencies and +# their tag names. +# TODO: Set tag inheritance for the created tag, using the build dependencies' +# tags. +# TODO: Ensure the RPM %dist tag is set according to the policy. +# TODO: Build the module components in the prepared tag. diff --git a/ridad.py b/ridad.py index 430fc094..ba25355f 100755 --- a/ridad.py +++ b/ridad.py @@ -31,36 +31,54 @@ This is the main component of the orchestrator and is responsible for proper scheduling component builds in the supported build systems. """ +import os +import threading import rida.config import rida.messaging # TODO: Load the config file from environment config = rida.config.from_file("rida.conf") -# TODO: Listen for bus messages from build systems about builds being done. -for msg in rida.messaging.listen(backend=config.messaging): - print("Saw %r with %r" % (msg['topic'], msg)) - if '.buildsys.build.state.change' in msg['topic']: - print("A build changed state in koji!!") - elif '.rida.module.state.change' in msg['topic']: - print("Our frontend says that a module changed state!!") - else: - pass - -# TODO: Periodically check the state of the build systems' tasks, in case some -# messages got lost. -# XXX - should we just do this with a cronjob external to this process? -# TODO: Emit messages about the module build being done. -# TODO; Watch the database and process modules in the wait state. -# TODO: Construct the name of the tag/target according to the policy and record -# it in PDC. -# TODO: Create the relevant koji tags and targets. -# TODO: Query the PDC to find what modules satisfy the build dependencies and -# their tag names. -# TODO: Set tag inheritance for the created tag, using the build dependencies' -# tags. -# TODO: Ensure the RPM %dist tag is set according to the policy. -# TODO: Build the module components in the prepared tag. +# TODO: Utilized rida.builder to prepare the buildroots and build components. # TODO: Set the build state to build once the module build is started. # TODO: Set the build state to done once the module build is done. # TODO: Set the build state to failed if the module build fails. + +class Messaging(threading.Thread): + def run(self): + while True: + # TODO: Listen for bus messages from rida about module builds + # entering the wait state + # TODO: Listen for bus messages from the buildsystem about + # component builds changing state + # TODO: Check for modules that can be set to done/failed + # TODO: Act on these things somehow + # TODO: Emit messages about doing so + for msg in rida.messaging.listen(backend=config.messaging): + print("Saw %r with %r" % (msg['topic'], msg)) + if '.buildsys.build.state.change' in msg['topic']: + print("A build changed state in koji!!") + elif '.rida.module.state.change' in msg['topic']: + print("Our frontend says that a module changed state!!") + else: + pass + +class Polling(threading.Thread): + def run(self): + while True: + # TODO: Check for module builds in the wait state + # TODO: Check component builds in the open state + # TODO: Check for modules that can be set to done/failed + # TODO: Act on these things somehow + # TODO: Emit messages about doing so + # TODO: Sleep for a configuration-determined interval + pass + +try: + messaging_thread = Messaging() + polling_thread = Polling() + messaging_thread.start() + polling_thread.start() +except KeyboardInterrupt: + # FIXME: Make this less brutal + os._exit()