diff options
author | Abhishek Kekane <akekane@redhat.com> | 2022-06-28 05:40:15 +0000 |
---|---|---|
committer | Dan Smith <dansmith@redhat.com> | 2022-06-28 10:43:30 -0700 |
commit | ea4ed6dfec2ade544ba30e3324e6c7def6a3eddd (patch) | |
tree | 94d87844ab494297a5d50114ffffdb0778ba2c49 | |
parent | 1964876644c7086eff516832a19206d28891110d (diff) | |
download | glance-ea4ed6dfec2ade544ba30e3324e6c7def6a3eddd.tar.gz |
[APIImpact] Correct API response code for DELETE cache APIs
DELETE /v2/cache/{image_id} and /v2/cache returns HTTP 200 response
code to user but as per proposal it should be HTTP 204. This change
returns HTTP 204 response to user.
Closes-Bug: #1980049
Change-Id: I9d1c25638584fe346e3937d0536413d548d46e8e
(cherry picked from commit a71f7ba44e57a7945addb82afd2a19962d5c04cc)
-rw-r--r-- | glance/api/v2/cached_images.py | 6 | ||||
-rw-r--r-- | glance/tests/functional/v2/test_cache_api.py | 4 | ||||
-rw-r--r-- | releasenotes/notes/bug-1980049-623d2eb0fa074136.yaml | 14 |
3 files changed, 22 insertions, 2 deletions
diff --git a/glance/api/v2/cached_images.py b/glance/api/v2/cached_images.py index 812ddb3cd..cefcd15c8 100644 --- a/glance/api/v2/cached_images.py +++ b/glance/api/v2/cached_images.py @@ -242,6 +242,12 @@ class CachedImageSerializer(wsgi.JSONResponseSerializer): def queue_image_from_api(self, response, result): response.status_int = 202 + def clear_cache(self, response, result): + response.status_int = 204 + + def delete_cache_entry(self, response, result): + response.status_int = 204 + def create_resource(): """Cached Images resource factory method""" diff --git a/glance/tests/functional/v2/test_cache_api.py b/glance/tests/functional/v2/test_cache_api.py index 4865c6d4f..35ddca169 100644 --- a/glance/tests/functional/v2/test_cache_api.py +++ b/glance/tests/functional/v2/test_cache_api.py @@ -85,12 +85,12 @@ class TestImageCache(functional.SynchronousAPIBase): response = self.api_put(path) self.assertEqual(expected_code, response.status_code) - def cache_delete(self, image_id, expected_code=200): + def cache_delete(self, image_id, expected_code=204): path = '/v2/cache/%s' % image_id response = self.api_delete(path) self.assertEqual(expected_code, response.status_code) - def cache_clear(self, target='', expected_code=200): + def cache_clear(self, target='', expected_code=204): path = '/v2/cache' headers = {} if target: diff --git a/releasenotes/notes/bug-1980049-623d2eb0fa074136.yaml b/releasenotes/notes/bug-1980049-623d2eb0fa074136.yaml new file mode 100644 index 000000000..544d0defc --- /dev/null +++ b/releasenotes/notes/bug-1980049-623d2eb0fa074136.yaml @@ -0,0 +1,14 @@ +--- +upgrade: + - | + The Image service API call ``DELETE /v2/cache/{image_id}`` and + ``DELETE /v2/cache`` now returns a 204 (No Content) response code + to indicate success. In glance 24.0.0 (the initial Yoga release), + it had mistakenly returned a 200. + +fixes: + - | + Bug `1980049 <https://bugs.launchpad.net/glance/+bug/1980049>`_: + Fixed the success response code of the REST API call + ``DELETE /v2/cache/{image_id}`` and ``DELETE /v2/cache`` to be + 204 (No Content), following the original design of the feature. |