From 12347e16c899936e4d9d12c506a88b0e84386b64 Mon Sep 17 00:00:00 2001 From: Pierre Riteau Date: Fri, 13 Oct 2023 10:27:49 +0200 Subject: [PATCH] Fix retrieval of reprocessing tasks Calling GET /v2/task/reprocesses with python-cloudkittyclient was returning Internal Server Error, with the following API trace: File "/var/lib/kolla/venv/lib/python3.6/site-packages/cloudkitty/api/v2/task/reprocess.py", line 259, in get order, ACCEPTED_GET_REPROCESSING_REQUEST_ORDERS) TypeError: __init__() takes from 1 to 3 positional arguments but 4 were given This was because http_exceptions.BadRequest was given multiple arguments (similar to LOG.* methods) instead of a single string. Another issue is that python-cloudkittyclient sends the "DESC" order while the API only supports "desc" and "asc". Convert to lower case for compatibility. Change-Id: Id1145adff82bc9a01e4eb0f306f0bfa535142459 --- cloudkitty/api/v2/task/reprocess.py | 8 ++++++-- .../notes/reprocess-get-fix-f2bd1f2f9e2d640e.yaml | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/reprocess-get-fix-f2bd1f2f9e2d640e.yaml diff --git a/cloudkitty/api/v2/task/reprocess.py b/cloudkitty/api/v2/task/reprocess.py index 197bb298..2d6deef0 100644 --- a/cloudkitty/api/v2/task/reprocess.py +++ b/cloudkitty/api/v2/task/reprocess.py @@ -286,10 +286,14 @@ class ReprocessSchedulerGetApi(base.BaseResource): if not isinstance(scope_ids, list): scope_ids = [scope_ids] + # Some versions of python-cloudkittyclient can send the order in upper + # case, e.g. "DESC". Convert it to lower case for compatibility. + order = order.lower() + if order not in ACCEPTED_GET_REPROCESSING_REQUEST_ORDERS: raise http_exceptions.BadRequest( - "The order [%s] is not valid. Accepted values are %s.", - order, ACCEPTED_GET_REPROCESSING_REQUEST_ORDERS) + "The order [%s] is not valid. Accepted values are %s." % + (order, ACCEPTED_GET_REPROCESSING_REQUEST_ORDERS)) schedules = self.schedule_reprocessing_db.get_all( identifier=scope_ids, remove_finished=False, diff --git a/releasenotes/notes/reprocess-get-fix-f2bd1f2f9e2d640e.yaml b/releasenotes/notes/reprocess-get-fix-f2bd1f2f9e2d640e.yaml new file mode 100644 index 00000000..e3b9c945 --- /dev/null +++ b/releasenotes/notes/reprocess-get-fix-f2bd1f2f9e2d640e.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fix retrieval of reprocessing tasks which was returning ``Internal Server + Error``.