]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: add more ContainerDeamonForm methods to the tracing class
authorJohn Mulligan <jmulligan@redhat.com>
Sun, 5 Nov 2023 16:00:54 +0000 (11:00 -0500)
committerJohn Mulligan <jmulligan@redhat.com>
Tue, 14 Nov 2023 21:05:48 +0000 (16:05 -0500)
Add methods customize_{container_envs,process_args} & default_entrypoint
to the tracing daemon type class. Use those methods in the get_container
function.
This change tries to adapt to, but not fix, the rather strange
set_configuration static method that side-effects the class's(!)
property.

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

index 171d2a1c928e68878584c77a32770d9136050a47..6c37a1fb4d21b5f59389208e064c02a0cc56e025 100755 (executable)
@@ -1846,6 +1846,18 @@ class Tracing(ContainerDaemonForm):
 
     def __init__(self, ident: DaemonIdentity) -> None:
         self._identity = ident
+        self._configured = False
+
+    def _configure(self, ctx: CephadmContext) -> None:
+        if self._configured:
+            return
+        config = fetch_configs(ctx)
+        # Currently, this method side-effects the class attribute, and that
+        # is unpleasant. In the future it would be nice to move all of
+        # set_configuration into _confiure and only modify each classes data
+        # independently
+        self.set_configuration(config, self.identity.daemon_type)
+        self._configured = True
 
     @classmethod
     def create(cls, ctx: CephadmContext, ident: DaemonIdentity) -> 'Tracing':
@@ -1867,6 +1879,28 @@ class Tracing(ContainerDaemonForm):
             'daemon_args', []
         )
 
+    def customize_process_args(
+        self, ctx: CephadmContext, args: List[str]
+    ) -> None:
+        self._configure(ctx)
+        # earlier code did an explicit check if the daemon type was jaeger-agent
+        # and would only call get_daemon_args if that was true. However, since
+        # the function only returns a non-empty list in the case of jaeger-agent
+        # that check is unnecessary and is not brought over.
+        args.extend(self.get_daemon_args())
+
+    def customize_container_envs(
+        self, ctx: CephadmContext, envs: List[str]
+    ) -> None:
+        self._configure(ctx)
+        envs.extend(
+            self.components[self.identity.daemon_type].get('envs', [])
+        )
+
+    def default_entrypoint(self) -> str:
+        return ''
+
+
 ##################################
 
 
@@ -2923,14 +2957,10 @@ def get_container(
         d_args.extend(monitoring.get_daemon_args())
         mounts = get_container_mounts(ctx, ident)
     elif daemon_type in Tracing.components:
-        entrypoint = ''
-        name = ident.daemon_name
-        config = fetch_configs(ctx)
-        Tracing.set_configuration(config, daemon_type)
-        envs.extend(Tracing.components[daemon_type].get('envs', []))
-        if daemon_type == 'jaeger-agent':
-            tracing = Tracing.create(ctx, ident)
-            d_args.extend(tracing.get_daemon_args())
+        tracing = Tracing.create(ctx, ident)
+        entrypoint = tracing.default_entrypoint()
+        tracing.customize_container_envs(ctx, envs)
+        tracing.customize_process_args(ctx, d_args)
     elif daemon_type == NFSGanesha.daemon_type:
         nfs_ganesha = NFSGanesha.create(ctx, ident)
         entrypoint = nfs_ganesha.default_entrypoint()