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
This commit is contained in:
Simon Westphahl 2021-05-05 14:01:31 +02:00
parent de00c44021
commit 48ef350cb2
2 changed files with 14 additions and 1 deletions

View File

@ -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)

View File

@ -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):