diff options
author | Felix Edel <felix.edel@bmw.de> | 2022-02-23 08:25:54 +0100 |
---|---|---|
committer | Felix Edel <felix.edel@bmw.de> | 2022-02-23 08:25:54 +0100 |
commit | 8b7535b7a0c12d69e79632e2b1f1a6aad5a9196d (patch) | |
tree | ea0802c4683af280bef265c4ba5f2417d70c7901 | |
parent | d5385d7fc58f98d719ebe981e053ff12e639aed6 (diff) | |
download | zuul-8b7535b7a0c12d69e79632e2b1f1a6aad5a9196d.tar.gz |
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
-rwxr-xr-x | tools/zuul-changes.py | 2 | ||||
-rwxr-xr-x | zuul/web/__init__.py | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/tools/zuul-changes.py b/tools/zuul-changes.py index 96aeb88f2..05f7fb33f 100755 --- a/tools/zuul-changes.py +++ b/tools/zuul-changes.py @@ -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']: diff --git a/zuul/web/__init__.py b/zuul/web/__init__.py index a3f7dcbcc..b92ccabea 100755 --- a/zuul/web/__init__.py +++ b/zuul/web/__init__.py @@ -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): |