]> git.apps.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)
committerSebastian Wagner <sebastian.wagner@suse.com>
Thu, 23 Jul 2020 13:20:10 +0000 (15:20 +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>
(cherry picked from commit 3c98f1553fe3b91777ee81d887d02462132475fb)

src/cephadm/cephadm

index abcd49c9d30baad01ed4fc1a00f0e0d1ba0e6f8e..18db5bdb3093e6b460e3ca6ba2ba6bdc142d8e92 100755 (executable)
@@ -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