python-cephclient: delete finished requests

ceph-mgr REST API supports synchronous and asynchronous requests.
In asynchronous mode clients can run multiple requests in parallel
then poll to get status of finished requests.

ceph-mgr restful plugin keeps a list of requests that were initiated
by the client and forwarded towards ceph-mgr. It expects the client
to delete finished requests after retrieving current status.

python-cephclient is making synchronous requests (using POST to
"/request?wait=1") but the server is converting them asynchronus
then polls for status on its side. So after getting a response back
the client is still expected to DELETE "/request?id=..."

Currently it's not doing that and ceph-mgr restful plugin is
accumulating a list of all requests ever made by python-cephclient

Change-Id: If8d5c8b27135fde45116e05bb04b655d9574c5ca
Closes-Bug: 1828549
Signed-off-by: Daniel Badea <daniel.badea@windriver.com>
This commit is contained in:
Daniel Badea 2019-05-10 11:23:31 +00:00
parent 6bc6aed3d4
commit 3f3e61f148

View File

@ -190,7 +190,10 @@ class CephClient(object):
verify=self.check_certificate,
timeout=timeout).json()
LOG.info('Result: {}'.format(result))
if 'is_finished' not in result:
if 'is_finished' in result:
self.session.delete(
self.service_url + 'request?id=' + result['id'])
else:
assert('message' in result)
if 'auth: No such user' in result['message']:
raise CephClientNoSuchUser(user=self.username)