From 48ef350cb2501ce5003aa2f71253e23a1bd454dc Mon Sep 17 00:00:00 2001 From: Simon Westphahl Date: Wed, 5 May 2021 14:01:31 +0200 Subject: [PATCH] Add pipeline event queue lengths to status JSON With the switch to the pipeline event queues we lost some visibility of the queue lenghts, since most of the event handling now happens for the pipelines. This change adds the queue lengths to the status JSON so we can display them in zuul-web later on. Change-Id: I876c3634b5616b6fc88f3ee529958b32f2ceda43 --- tests/unit/test_web.py | 3 +++ zuul/scheduler.py | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/unit/test_web.py b/tests/unit/test_web.py index 516070f8f1..38c2879c8b 100644 --- a/tests/unit/test_web.py +++ b/tests/unit/test_web.py @@ -149,6 +149,9 @@ class TestWeb(BaseTestWeb): data = resp.json() status_jobs = [] for p in data['pipelines']: + self.assertEqual(p["trigger_events"], 0) + self.assertEqual(p["result_events"], 0) + self.assertEqual(p["management_events"], 0) for q in p['change_queues']: if p['name'] in ['gate', 'conflict']: self.assertEqual(q['window'], 20) diff --git a/zuul/scheduler.py b/zuul/scheduler.py index 8bb575ecaf..1767478853 100644 --- a/zuul/scheduler.py +++ b/zuul/scheduler.py @@ -1855,8 +1855,18 @@ class Scheduler(threading.Thread): "message": "Tenant %s isn't ready" % tenant_name, "code": 204 }) + trigger_event_queues = self.pipeline_trigger_events[tenant_name] + result_event_queues = self.pipeline_result_events[tenant_name] + management_event_queues = self.pipeline_management_events[tenant_name] for pipeline in tenant.layout.pipelines.values(): - pipelines.append(pipeline.formatStatusJSON(websocket_url)) + status = pipeline.formatStatusJSON(websocket_url) + status['trigger_events'] = len( + trigger_event_queues[pipeline.name]) + status['result_events'] = len( + result_event_queues[pipeline.name]) + status['management_events'] = len( + management_event_queues[pipeline.name]) + pipelines.append(status) return json.dumps(data) def onChangeUpdated(self, change, event):