From: Aishwarya Mathuria Date: Wed, 15 Sep 2021 18:10:57 +0000 (+0530) Subject: lock/ops.py: Fix retry mechanism for unlock_one X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=c25926b644a6383fa42b1dfbf6f0102dac825b55;p=teuthology.git lock/ops.py: Fix retry mechanism for unlock_one In unlock_one, we currently have a retry mechanism that is only triggered on a particular exception. With this change, we retry the request to unlock no matter what the cause of failure. Fixes: https://tracker.ceph.com/issues/50921 Signed-off-by: Aishwarya Mathuria --- diff --git a/teuthology/lock/ops.py b/teuthology/lock/ops.py index 27fb68935e..7ad8bb1704 100644 --- a/teuthology/lock/ops.py +++ b/teuthology/lock/ops.py @@ -204,21 +204,19 @@ def unlock_one(ctx, name, user, description=None): while proceed(): try: response = requests.put(uri, json.dumps(request)) - break + if response.ok: + log.info('unlocked: %s', name) + return response.ok # Work around https://github.com/kennethreitz/requests/issues/2364 except requests.ConnectionError as e: log.warn("Saw %s while unlocking; retrying...", str(e)) - success = response.ok - if success: - log.info('unlocked %s', name) - else: - try: - reason = response.json().get('message') - except ValueError: - reason = str(response.status_code) - log.error('failed to unlock {node}. reason: {reason}'.format( - node=name, reason=reason)) - return success + try: + reason = response.json().get('message') + except ValueError: + reason = str(response.status_code) + log.error('failed to unlock {node}. reason: {reason}'.format( + node=name, reason=reason)) + return False def update_lock(name, description=None, status=None, ssh_pub_key=None):