From 34d19163fcd0898d191a0b1643c7cccaae0e2929 Mon Sep 17 00:00:00 2001 From: Kyr Shatskyy Date: Thu, 1 Aug 2024 12:04:42 +0200 Subject: [PATCH] lock/ops: try to stop_node before unlock We should try to call stop_node before unlock and don't even try to do this for vms. Signed-off-by: Kyr Shatskyy --- teuthology/lock/ops.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/teuthology/lock/ops.py b/teuthology/lock/ops.py index da21dc7d75..fbb7fb6fbb 100644 --- a/teuthology/lock/ops.py +++ b/teuthology/lock/ops.py @@ -227,6 +227,13 @@ def unlock_one(name, user, description=None, status: Union[dict, None] = None) - if not teuthology.provision.destroy_if_vm(name, user, description or ""): log.error('destroy failed for %s', name) return False + # we're trying to stop node before actual unlocking + status_info = teuthology.lock.query.get_status(name) + try: + if not teuthology.lock.query.is_vm(status=status_info): + stop_node(name, status) + except Exception: + log.exception(f"Failed to stop {name}!") request = dict(name=name, locked=False, locked_by=user, description=description) uri = os.path.join(config.lock_server, 'nodes', name, 'lock', '') @@ -237,10 +244,6 @@ def unlock_one(name, user, description=None, status: Union[dict, None] = None) - response = requests.put(uri, json.dumps(request)) if response.ok: log.info('unlocked: %s', name) - try: - stop_node(name, status) - except Exception: - log.exception(f"Failed to stop {name}!") return response.ok if response.status_code == 403: break -- 2.39.5