]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: move data_dir check to earlier in the function
authorJohn Mulligan <jmulligan@redhat.com>
Fri, 4 Oct 2024 18:14:04 +0000 (14:14 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Tue, 11 Feb 2025 21:08:04 +0000 (16:08 -0500)
Move the check for data_dir earlier in the list_daemons function.
Having the check performed ealier means we can fail fast and avoid
calling container engine commands if we're not going to be returning any
useful results because data dir is missing.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/cephadm.py

index edd84e240caed4bea1b74d63f68d34fc52ddddb4..a695b4beb39bbe1f7b3e7b325c2d96a55f7a2992 100755 (executable)
@@ -3411,6 +3411,11 @@ def list_daemons(
     if legacy_dir is not None:
         data_dir = os.path.abspath(legacy_dir + data_dir)
 
+    if not os.path.exists(data_dir):
+        # data_dir (/var/lib/ceph typically) is missing. Return empty list.
+        logger.warning('%s is missing: no daemon listing available', data_dir)
+        return []
+
     # keep track of ceph versions we see
     seen_versions: Dict[str, Optional[str]] = {}
 
@@ -3421,11 +3426,6 @@ def list_daemons(
     seen_memusage_cid_len, seen_memusage = parsed_container_mem_usage(ctx)
     seen_cpuperc_cid_len, seen_cpuperc = parsed_container_cpu_perc(ctx)
 
-    if not os.path.exists(data_dir):
-        # data_dir (/var/lib/ceph typically) is missing. Return empty list.
-        logger.warning('%s is missing: no daemon listing available', data_dir)
-        return []
-
     for i in os.listdir(data_dir):
         if i in ['mon', 'osd', 'mds', 'mgr', 'rgw']:
             if type_of_daemon and type_of_daemon != i: