]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: fix creating custom Prometheus image
authorPatrick Seidensal <pseidensal@suse.com>
Tue, 7 Jul 2020 11:58:27 +0000 (13:58 +0200)
committerPatrick Seidensal <pseidensal@suse.com>
Fri, 17 Jul 2020 12:44:24 +0000 (14:44 +0200)
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 <pseidensal@suse.com>
src/cephadm/cephadm

index dad1a361f2f15036ecea1e58f8c23afc80ad297a..861387763968c6715d3551abdecc3af72860c58c 100755 (executable)
@@ -1240,18 +1240,18 @@ def make_data_dir_base(fsid, uid, gid):
     return data_dir_base
 
 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)
     return data_dir
 
 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