From ae90d5f2c7905487d3f14081ed7458969242c4fc Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Thu, 12 Nov 2020 19:48:29 +0100 Subject: [PATCH] builder: log compose-status.json during the build Instead of just uploading the compose-status.json at the very end of the build, keep updating it every time it is fetch. This makes it easier to follow along, especially if there are multiple image request being built. --- plugins/builder/osbuild.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/builder/osbuild.py b/plugins/builder/osbuild.py index 21f6f29..45d3e69 100644 --- a/plugins/builder/osbuild.py +++ b/plugins/builder/osbuild.py @@ -236,9 +236,12 @@ class Client: return ComposeLogs.from_dict(res.json()) - def wait_for_compose(self, compose_id: str, *, sleep_time=2): + def wait_for_compose(self, compose_id: str, *, sleep_time=2, callback=None): while True: status = self.compose_status(compose_id) + if callback: + callback(status) + if status.is_finished: return status @@ -349,6 +352,9 @@ class OSBuildImage(BaseTaskHandler): arch='noarch') self.wait(task) + def on_status_update(self, status: ComposeStatus): + self.upload_json(status.as_dict(), "compose-status") + # pylint: disable=arguments-differ def handler(self, name, version, distro, image_types, target, arches, opts): """Main entry point for the task""" @@ -400,12 +406,11 @@ class OSBuildImage(BaseTaskHandler): self.logger.info("Compose id: %s, Koji build id: %s", cid, bid) self.logger.debug("Waiting for comose to finish") - status = client.wait_for_compose(cid) + status = client.wait_for_compose(cid, callback=self.on_status_update) self.logger.debug("Compose finished: %s", str(status.as_dict())) self.logger.info("Compose result: %s", status.status) - self.upload_json(status.as_dict(), "compose-status") self.attach_logs(cid, ireqs) if not status.is_success: