]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: add more ContainerDeamonForm methods to the monitoring class
authorJohn Mulligan <jmulligan@redhat.com>
Sun, 5 Nov 2023 16:09:27 +0000 (11:09 -0500)
committerJohn Mulligan <jmulligan@redhat.com>
Tue, 14 Nov 2023 21:05:48 +0000 (16:05 -0500)
Add methods customize_{container_args,process_args} & default_entrypoint
to the monitoring daemon type class. Use those methods in the
get_container function.

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

index 6c37a1fb4d21b5f59389208e064c02a0cc56e025..b704e50c9c49ca84ba2f8d983dae6d8492e90527 100755 (executable)
@@ -872,6 +872,31 @@ class Monitoring(ContainerDaemonForm):
         data_dir = self.identity.data_dir(ctx.data_dir)
         mounts.update(self._get_container_mounts(data_dir))
 
+    def customize_container_args(
+        self, ctx: CephadmContext, args: List[str]
+    ) -> None:
+        uid, _ = self.uid_gid(ctx)
+        monitoring_args = [
+            '--user',
+            str(uid),
+            # FIXME: disable cpu/memory limits for the time being (not supported
+            # by ubuntu 18.04 kernel!)
+        ]
+        args.extend(monitoring_args)
+        if self.identity.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
+            args.extend(['--security-opt', 'label=disable'])
+
+    def customize_process_args(
+        self, ctx: CephadmContext, args: List[str]
+    ) -> None:
+        args.extend(self.get_daemon_args())
+
+    def default_entrypoint(self) -> str:
+        return ''
+
 ##################################
 
 
@@ -2939,22 +2964,10 @@ def get_container(
         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'])
         monitoring = Monitoring.create(ctx, ident)
-        d_args.extend(monitoring.get_daemon_args())
+        entrypoint = monitoring.default_entrypoint()
+        monitoring.customize_container_args(ctx, container_args)
+        monitoring.customize_process_args(ctx, d_args)
         mounts = get_container_mounts(ctx, ident)
     elif daemon_type in Tracing.components:
         tracing = Tracing.create(ctx, ident)