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
This commit is contained in:
Pierre Riteau 2023-10-13 10:27:49 +02:00
parent b96b9afc68
commit 12347e16c8
2 changed files with 11 additions and 2 deletions

View File

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

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fix retrieval of reprocessing tasks which was returning ``Internal Server
Error``.