diff options
author | Abhishek Kekane <akekane@redhat.com> | 2022-05-04 05:41:56 +0000 |
---|---|---|
committer | Abhishek Kekane <akekane@redhat.com> | 2022-05-11 05:26:40 +0000 |
commit | 9043efc5fff4daf83fdbcba1e200ab2e113e0464 (patch) | |
tree | 773b2bd5239c75c81d9bdda9a44090e923ec90b8 | |
parent | 1beee78e096ddba4729be10af6ac4ddec8e79da0 (diff) | |
download | glance-9043efc5fff4daf83fdbcba1e200ab2e113e0464.tar.gz |
[APIImpact] Correct API response code for PUT /v2/cache/{image_id}
PUT /v2/cache/{image_id} returns HTTP 200 response code to user but as per
proposal it should be HTTP 202. This change returns HTTP 202 response to
user.
Closes-Bug: #1971521
Change-Id: I6a875a38bef5beafe352ab3320f3fd199db89aa1
(cherry picked from commit ecb040c17786fa28d521a247c556a99442e37d5f)
-rw-r--r-- | api-ref/source/v2/cache-manage.inc | 2 | ||||
-rw-r--r-- | glance/api/v2/cached_images.py | 4 | ||||
-rw-r--r-- | glance/tests/functional/v2/test_cache_api.py | 2 |
3 files changed, 5 insertions, 3 deletions
diff --git a/api-ref/source/v2/cache-manage.inc b/api-ref/source/v2/cache-manage.inc index 1993cb191..f0d5597d4 100644 --- a/api-ref/source/v2/cache-manage.inc +++ b/api-ref/source/v2/cache-manage.inc @@ -33,7 +33,7 @@ Queue image Queues image for caching. *(Since Image API v2.14)* -Normal response codes: 200 +Normal response codes: 202 Error response codes: 400, 401, 403, 404 diff --git a/glance/api/v2/cached_images.py b/glance/api/v2/cached_images.py index 002b8cf9b..812ddb3cd 100644 --- a/glance/api/v2/cached_images.py +++ b/glance/api/v2/cached_images.py @@ -238,7 +238,9 @@ class CachedImageDeserializer(wsgi.JSONRequestDeserializer): class CachedImageSerializer(wsgi.JSONResponseSerializer): - pass + + def queue_image_from_api(self, response, result): + response.status_int = 202 def create_resource(): diff --git a/glance/tests/functional/v2/test_cache_api.py b/glance/tests/functional/v2/test_cache_api.py index bd3048aef..4865c6d4f 100644 --- a/glance/tests/functional/v2/test_cache_api.py +++ b/glance/tests/functional/v2/test_cache_api.py @@ -79,7 +79,7 @@ class TestImageCache(functional.SynchronousAPIBase): if response.status_code == 200: return response.json - def cache_queue(self, image_id, expected_code=200): + def cache_queue(self, image_id, expected_code=202): # Queue image for prefetching path = '/v2/cache/%s' % image_id response = self.api_put(path) |