]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
lock/ops: try to stop_node before unlock 1989/head
authorKyr Shatskyy <kyrylo.shatskyy@clyso.com>
Thu, 1 Aug 2024 10:04:42 +0000 (12:04 +0200)
committerKyr Shatskyy <kyrylo.shatskyy@clyso.com>
Fri, 2 Aug 2024 18:20:28 +0000 (20:20 +0200)
We should try to call stop_node before unlock and don't
even try to do this for vms.

Signed-off-by: Kyr Shatskyy <kyrylo.shatskyy@clyso.com>
teuthology/lock/ops.py

index da21dc7d752405794e78fc71c2bba61e9012800d..fbb7fb6fbbfbce457cc158be4d18cd529013ad95 100644 (file)
@@ -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