]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: consolidate if-blocks in get_container function
authorJohn Mulligan <jmulligan@redhat.com>
Thu, 19 Oct 2023 18:48:17 +0000 (14:48 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Sat, 4 Nov 2023 18:53:06 +0000 (14:53 -0400)
Instead of having a number of separate if-statement blocks try to
reduce the number of sections so that you can look at one block
and see what the function is doing for that daemon type.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/cephadm.py

index 326c7aaa106392603b83b10564330ae100ceb65a..b96e3be6d2cf9ae9119302bd9f6440321794d1b0 100755 (executable)
@@ -2741,20 +2741,38 @@ def get_container(
     if daemon_type == 'rgw':
         entrypoint = '/usr/bin/radosgw'
         name = 'client.rgw.%s' % ident.daemon_id
+        ceph_args = ['-n', name, '-f']
     elif daemon_type == 'rbd-mirror':
         entrypoint = '/usr/bin/rbd-mirror'
         name = 'client.rbd-mirror.%s' % ident.daemon_id
+        ceph_args = ['-n', name, '-f']
     elif daemon_type == 'cephfs-mirror':
         entrypoint = '/usr/bin/cephfs-mirror'
         name = 'client.cephfs-mirror.%s' % ident.daemon_id
+        ceph_args = ['-n', name, '-f']
     elif daemon_type == 'crash':
         entrypoint = '/usr/bin/ceph-crash'
         name = 'client.crash.%s' % ident.daemon_id
+        ceph_args = ['-n', name]
     elif daemon_type in ['mon', 'mgr', 'mds', 'osd']:
         entrypoint = '/usr/bin/ceph-' + daemon_type
         name = ident.daemon_name
+        ceph_args = ['-n', name, '-f']
     elif daemon_type in Monitoring.components:
         entrypoint = ''
+        uid, gid = Monitoring.extract_uid_gid(ctx, daemon_type)
+        monitoring_args = [
+            '--user',
+            str(uid),
+            # FIXME: disable cpu/memory limits for the time being (not supported
+            # by ubuntu 18.04 kernel!)
+        ]
+        container_args.extend(monitoring_args)
+        if daemon_type == 'node-exporter':
+            # in order to support setting '--path.procfs=/host/proc','--path.sysfs=/host/sys',
+            # '--path.rootfs=/rootfs' for node-exporter we need to disable selinux separation
+            # between the node-exporter container and the host to avoid selinux denials
+            container_args.extend(['--security-opt', 'label=disable'])
     elif daemon_type in Tracing.components:
         entrypoint = ''
         name = ident.daemon_name
@@ -2768,6 +2786,7 @@ def get_container(
     elif daemon_type == CephExporter.daemon_type:
         entrypoint = CephExporter.entrypoint
         name = 'client.ceph-exporter.%s' % ident.daemon_id
+        ceph_args = ['-n', name, '-f']
     elif daemon_type == HAproxy.daemon_type:
         name = ident.daemon_name
         container_args.extend(['--user=root'])  # haproxy 2.4 defaults to a different user
@@ -2792,25 +2811,6 @@ def get_container(
         host_network = False
         envs.extend(cc.get_container_envs())
         container_args.extend(cc.get_container_args())
-
-    if daemon_type in Monitoring.components:
-        uid, gid = Monitoring.extract_uid_gid(ctx, daemon_type)
-        monitoring_args = [
-            '--user',
-            str(uid),
-            # FIXME: disable cpu/memory limits for the time being (not supported
-            # by ubuntu 18.04 kernel!)
-        ]
-        container_args.extend(monitoring_args)
-        if daemon_type == 'node-exporter':
-            # in order to support setting '--path.procfs=/host/proc','--path.sysfs=/host/sys',
-            # '--path.rootfs=/rootfs' for node-exporter we need to disable selinux separation
-            # between the node-exporter container and the host to avoid selinux denials
-            container_args.extend(['--security-opt', 'label=disable'])
-    elif daemon_type == 'crash':
-        ceph_args = ['-n', name]
-    elif daemon_type in ceph_daemons():
-        ceph_args = ['-n', name, '-f']
     elif daemon_type == SNMPGateway.daemon_type:
         sg = SNMPGateway.init(ctx, ident.fsid, ident.daemon_id)
         container_args.append(