From d97e7da4093fcb7afa2913abd7f2ba360c1923d3 Mon Sep 17 00:00:00 2001 From: Patrick Seidensal Date: Tue, 7 Jul 2020 13:58:27 +0200 Subject: [PATCH] cephadm: fix creating custom Prometheus image Fix the code by improving a condition where a zero as uid or gid leads to an additional attempt to extract the uid/gid instead of uid/gid simply being used correctly. Fixes: https://tracker.ceph.com/issues/46398 Signed-off-by: Patrick Seidensal (cherry picked from commit 3c98f1553fe3b91777ee81d887d02462132475fb) --- src/cephadm/cephadm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index abcd49c9d30ba..18db5bdb3093e 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -1275,9 +1275,9 @@ def make_data_dir_base(fsid, uid, gid): def make_data_dir(fsid, daemon_type, daemon_id, uid=None, gid=None): - # type: (str, str, Union[int, str], int, int) -> str - if not uid or not gid: - (uid, gid) = extract_uid_gid() + # type: (str, str, Union[int, str], Optional[int], Optional[int]) -> str + if uid is None or gid is None: + uid, gid = extract_uid_gid() make_data_dir_base(fsid, uid, gid) data_dir = get_data_dir(fsid, daemon_type, daemon_id) makedirs(data_dir, uid, gid, DATA_DIR_MODE) @@ -1285,9 +1285,9 @@ def make_data_dir(fsid, daemon_type, daemon_id, uid=None, gid=None): def make_log_dir(fsid, uid=None, gid=None): - # type: (str, int, int) -> str - if not uid or not gid: - (uid, gid) = extract_uid_gid() + # type: (str, Optional[int], Optional[int]) -> str + if uid is None or gid is None: + uid, gid = extract_uid_gid() log_dir = get_log_dir(fsid) makedirs(log_dir, uid, gid, LOG_DIR_MODE) return log_dir -- 2.39.5