From: John Mulligan Date: Fri, 4 Oct 2024 18:14:04 +0000 (-0400) Subject: cephadm: move data_dir check to earlier in the function X-Git-Tag: v20.3.0~256^2~15 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1aa5e9fe204e1abf5300eb2f2dccb080b048bddd;p=ceph.git cephadm: move data_dir check to earlier in the function 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 --- diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index edd84e240ca..a695b4beb39 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -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: