Don't fail on missing change_queues key in status json
Since the pipeline state is stored in ZooKeeper, there could be cases where the change_queues key is missing in the status json. This makes API requests fail: 2022-02-22 17:56:18,390 ERROR cherrypy.error.139989033522128: [22/Feb/2022:17:56:18] HTTP Traceback (most recent call last): File "/opt/zuul/lib/python3.8/site-packages/cherrypy/_cprequest.py", line 638, in respond self._do_respond(path_info) File "/opt/zuul/lib/python3.8/site-packages/cherrypy/_cprequest.py", line 697, in _do_respond response.body = self.handler() File "/opt/zuul/lib/python3.8/site-packages/cherrypy/lib/encoding.py", line 223, in __call__ self.body = self.oldhandler(*args, **kwargs) File "/opt/zuul/lib/python3.8/site-packages/cherrypy/lib/jsontools.py", line 59, in json_handler value = cherrypy.serving.request._json_inner_handler(*args, **kwargs) File "/opt/zuul/lib/python3.8/site-packages/cherrypy/_cpdispatch.py", line 54, in __call__ return self.callable(*self.args, **self.kwargs) File "/opt/zuul/lib/python3.8/site-packages/zuul/web/__init__.py", line 1050, in status_change return result_filter.filterPayload(payload) File "/opt/zuul/lib/python3.8/site-packages/zuul/web/__init__.py", line 193, in filterPayload for change_queue in pipeline['change_queues']: KeyError: 'change_queues' Fix this by using a .get() call rather than directly accessing the dictionary key by name. A similar issue was already fixed in [1]. [1]: https://review.opendev.org/c/zuul/zuul/+/829018 Change-Id: I947f58f02c3da7dad35d1fc186c7026800f7cbdd
This commit is contained in:
parent
d5385d7fc5
commit
8b7535b7a0
@ -63,7 +63,7 @@ for tenant in tenants:
|
||||
for pipeline in data['pipelines']:
|
||||
if options.pipeline and pipeline['name'] != options.pipeline:
|
||||
continue
|
||||
for queue in pipeline['change_queues']:
|
||||
for queue in pipeline.get('change_queues', []):
|
||||
for head in queue['heads']:
|
||||
for change in head:
|
||||
if not change['live']:
|
||||
|
@ -207,7 +207,7 @@ class ChangeFilter(object):
|
||||
def filterPayload(self, payload):
|
||||
status = []
|
||||
for pipeline in payload['pipelines']:
|
||||
for change_queue in pipeline['change_queues']:
|
||||
for change_queue in pipeline.get('change_queues', []):
|
||||
for head in change_queue['heads']:
|
||||
for change in head:
|
||||
if self.wantChange(change):
|
||||
|
Loading…
Reference in New Issue
Block a user