From: John Mulligan Date: Sun, 5 Nov 2023 16:00:54 +0000 (-0500) Subject: cephadm: add more ContainerDeamonForm methods to the tracing class X-Git-Tag: v19.0.0~79^2~5 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=c701621ad9a3452bf0548a2d8283e88e9f7d6945;p=ceph.git cephadm: add more ContainerDeamonForm methods to the tracing class 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 --- diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index 171d2a1c928e6..6c37a1fb4d21b 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -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()