From 9e5ce8761407cd2ab38e86ab92f3bc985ac80d1e Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Wed, 26 Jul 2023 13:33:24 -0400 Subject: [PATCH] cephadm: convert get_daemon_args to use DaemonIdentity argument Signed-off-by: John Mulligan --- src/cephadm/cephadm.py | 20 ++++++++++---------- src/cephadm/tests/test_cephadm.py | 4 +++- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index 12276e52d9d..962f40c5dba 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -2026,10 +2026,10 @@ def should_log_to_journald(ctx: CephadmContext) -> bool: ctx.container_engine.version >= CGROUPS_SPLIT_PODMAN_VERSION -def get_daemon_args(ctx, fsid, daemon_type, daemon_id): - # type: (CephadmContext, str, str, Union[int, str]) -> List[str] +def get_daemon_args(ctx: CephadmContext, ident: 'DaemonIdentity') -> List[str]: r = list() # type: List[str] + daemon_type = ident.daemon_type if daemon_type in Ceph.daemons and daemon_type not in ['crash', 'ceph-exporter']: r += [ '--setuser', 'ceph', @@ -2119,19 +2119,19 @@ def get_daemon_args(ctx, fsid, daemon_type, daemon_id): elif daemon_type == 'jaeger-agent': r.extend(Tracing.components[daemon_type]['daemon_args']) elif daemon_type == NFSGanesha.daemon_type: - nfs_ganesha = NFSGanesha.init(ctx, fsid, daemon_id) + nfs_ganesha = NFSGanesha.init(ctx, ident.fsid, ident.daemon_id) r += nfs_ganesha.get_daemon_args() elif daemon_type == CephExporter.daemon_type: - ceph_exporter = CephExporter.init(ctx, fsid, daemon_id) + ceph_exporter = CephExporter.init(ctx, ident.fsid, ident.daemon_id) r.extend(ceph_exporter.get_daemon_args()) elif daemon_type == HAproxy.daemon_type: - haproxy = HAproxy.init(ctx, fsid, daemon_id) + haproxy = HAproxy.init(ctx, ident.fsid, ident.daemon_id) r += haproxy.get_daemon_args() elif daemon_type == CustomContainer.daemon_type: - cc = CustomContainer.init(ctx, fsid, daemon_id) + cc = CustomContainer.init(ctx, ident.fsid, ident.daemon_id) r.extend(cc.get_daemon_args()) elif daemon_type == SNMPGateway.daemon_type: - sc = SNMPGateway.init(ctx, fsid, daemon_id) + sc = SNMPGateway.init(ctx, ident.fsid, ident.daemon_id) r.extend(sc.get_daemon_args()) return r @@ -2794,7 +2794,7 @@ def get_container(ctx: CephadmContext, ctx, ident=ident, entrypoint=entrypoint, - args=ceph_args + get_daemon_args(ctx, fsid, daemon_type, daemon_id), + args=ceph_args + get_daemon_args(ctx, ident), container_args=container_args, volume_mounts=get_container_mounts(ctx, ident), bind_mounts=get_container_binds(ctx, ident), @@ -2893,7 +2893,7 @@ def deploy_daemon( '--fsid', fsid, '-c', '/tmp/config', '--keyring', '/tmp/keyring', - ] + get_daemon_args(ctx, fsid, 'mon', daemon_id), + ] + get_daemon_args(ctx, ident), volume_mounts={ log_dir: '/var/log/ceph:z', mon_dir: '/var/lib/ceph/mon/ceph-%s:z' % (daemon_id), @@ -4965,7 +4965,7 @@ def prepare_create_mon( '-c', '/dev/null', '--monmap', '/tmp/monmap', '--keyring', '/tmp/keyring', - ] + get_daemon_args(ctx, fsid, 'mon', mon_id), + ] + get_daemon_args(ctx, ident), volume_mounts={ log_dir: '/var/log/ceph:z', mon_dir: '/var/lib/ceph/mon/ceph-%s:z' % (mon_id), diff --git a/src/cephadm/tests/test_cephadm.py b/src/cephadm/tests/test_cephadm.py index b43f7fa1217..1fcf1558b5b 100644 --- a/src/cephadm/tests/test_cephadm.py +++ b/src/cephadm/tests/test_cephadm.py @@ -1220,7 +1220,9 @@ class TestMonitoring(object): daemon_type = 'prometheus' daemon_id = 'home' fsid = 'aaf5a720-13fe-4a3b-82b9-2d99b7fd9704' - args = _cephadm.get_daemon_args(ctx, fsid, daemon_type, daemon_id) + args = _cephadm.get_daemon_args( + ctx, _cephadm.DaemonIdentity(fsid, daemon_type, daemon_id) + ) assert any([x.startswith('--web.external-url=http://') for x in args]) @mock.patch('cephadm.call') -- 2.39.5