]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: fix custom alertmanager
authorPatrick Seidensal <pseidensal@suse.com>
Thu, 30 Jul 2020 09:37:46 +0000 (11:37 +0200)
committerPatrick Seidensal <pseidensal@suse.com>
Wed, 5 Aug 2020 10:14:28 +0000 (12:14 +0200)
When alertmanager image has been customized and does not have a
/etc/alertmanager directory, the uid/gid extraction fails. This change
assumes that instead the /etc/prometheus directory exists and can be
used to extract the uid and gid.

Signed-off-by: Patrick Seidensal <pseidensal@suse.com>
src/cephadm/cephadm

index ee72635e0e19bf3ce030c78f13164ab7255b4c99..a61a1184cbaa06ed3af424fb190cab88a8d13589 100755 (executable)
@@ -1848,18 +1848,28 @@ def get_container(fsid, daemon_type, daemon_id,
 
 
 def extract_uid_gid(img='', file_path='/var/lib/ceph'):
-    # type: (str, str) -> Tuple[int, int]
+    # type: (str, Union[str, Iterabe[str]]) -> Tuple[int, int]
 
     if not img:
         img = args.image
 
-    out = CephContainer(
-        image=img,
-        entrypoint='stat',
-        args=['-c', '%u %g', file_path]
-    ).run()
-    (uid, gid) = out.split(' ')
-    return int(uid), int(gid)
+    if isinstance(file_path, str):
+        paths = [file_path]
+    else:
+        paths = file_path
+
+    for fp in paths:
+        try:
+            out = CephContainer(
+                image=img,
+                entrypoint='stat',
+                args=['-c', '%u %g', fp]
+            ).run()
+            uid, gid = out.split(' ')
+            return int(uid), int(gid)
+        except RuntimeError:
+            pass
+    raise RuntimeError('uid/gid not found')
 
 
 def deploy_daemon(fsid, daemon_type, daemon_id, c, uid, gid,
@@ -3040,7 +3050,7 @@ def extract_uid_gid_monitoring(daemon_type):
     elif daemon_type == 'grafana':
         uid, gid = extract_uid_gid(file_path='/var/lib/grafana')
     elif daemon_type == 'alertmanager':
-        uid, gid = extract_uid_gid(file_path='/etc/alertmanager')
+        uid, gid = extract_uid_gid(file_path=['/etc/alertmanager', '/etc/prometheus'])
     else:
         raise Error("{} not implemented yet".format(daemon_type))
     return uid, gid