From be96c64bc9298553e6f7e33fc142329495efe4e8 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Wed, 26 Jul 2023 13:44:58 -0400 Subject: [PATCH] cephadm: convert deploy_daemon_units to to use a DaemonIdentity argument Signed-off-by: John Mulligan --- src/cephadm/cephadm.py | 38 ++++++++++++++++++++++--------- src/cephadm/tests/test_cephadm.py | 33 ++++++++------------------- 2 files changed, 36 insertions(+), 35 deletions(-) diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index 962f40c5dbac4..1371e02acb202 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -2920,9 +2920,16 @@ def deploy_daemon( cephadm_agent.deploy_daemon_unit(config_js) else: if c: - deploy_daemon_units(ctx, fsid, uid, gid, daemon_type, daemon_id, - c, osd_fsid=osd_fsid, endpoints=endpoints, - init_containers=init_containers) + deploy_daemon_units( + ctx, + ident, + uid, + gid, + c, + osd_fsid=osd_fsid, + endpoints=endpoints, + init_containers=init_containers, + ) else: raise RuntimeError('attempting to deploy a daemon without a container image') @@ -3070,11 +3077,9 @@ def clean_cgroup(ctx: CephadmContext, fsid: str, unit_name: str) -> None: def deploy_daemon_units( ctx: CephadmContext, - fsid: str, + ident: 'DaemonIdentity', uid: int, gid: int, - daemon_type: str, - daemon_id: Union[int, str], container: 'CephContainer', enable: bool = True, start: bool = True, @@ -3084,7 +3089,11 @@ def deploy_daemon_units( ) -> None: # cmd - ident = DaemonIdentity(fsid, daemon_type, daemon_id) + # unpack values from ident because they're used very frequently + fsid = ident.fsid + daemon_type = ident.daemon_type + daemon_id = ident.daemon_id + data_dir = get_data_dir(ident, ctx.data_dir) run_file_path = data_dir + '/unit.run' meta_file_path = data_dir + '/unit.meta' @@ -6997,10 +7006,17 @@ def command_adopt_ceph(ctx, daemon_type, daemon_id, fsid): logger.info('Creating new units...') make_var_run(ctx, fsid, uid, gid) c = get_container(ctx, fsid, daemon_type, daemon_id) - deploy_daemon_units(ctx, fsid, uid, gid, daemon_type, daemon_id, c, - enable=True, # unconditionally enable the new unit - start=(state == 'running' or ctx.force_start), - osd_fsid=osd_fsid) + ident = DaemonIdentity(fsid, daemon_type, daemon_id) + deploy_daemon_units( + ctx, + ident, + uid, + gid, + c, + enable=True, # unconditionally enable the new unit + start=(state == 'running' or ctx.force_start), + osd_fsid=osd_fsid, + ) update_firewalld(ctx, daemon_type) diff --git a/src/cephadm/tests/test_cephadm.py b/src/cephadm/tests/test_cephadm.py index 1fcf1558b5b81..1a90876202faf 100644 --- a/src/cephadm/tests/test_cephadm.py +++ b/src/cephadm/tests/test_cephadm.py @@ -1741,15 +1741,12 @@ class TestIscsi: _cephadm.get_parm.return_value = config_json c = _cephadm.get_container(ctx, fsid, 'iscsi', 'daemon_id') - _cephadm.make_data_dir( - ctx, _cephadm.DaemonIdentity(fsid, 'iscsi', 'daemon_id') - ) + ident = _cephadm.DaemonIdentity(fsid, 'iscsi', 'daemon_id') + _cephadm.make_data_dir(ctx, ident) _cephadm.deploy_daemon_units( ctx, - fsid, + ident, 0, 0, - 'iscsi', - 'daemon_id', c, True, True ) @@ -2293,10 +2290,8 @@ class TestSNMPGateway: _cephadm.deploy_daemon_units( ctx, - fsid, + ident, 0, 0, - 'snmp-gateway', - 'daemon_id', c, True, True ) @@ -2324,10 +2319,8 @@ class TestSNMPGateway: _cephadm.deploy_daemon_units( ctx, - fsid, + ident, 0, 0, - 'snmp-gateway', - 'daemon_id', c, True, True ) @@ -2355,10 +2348,8 @@ class TestSNMPGateway: _cephadm.deploy_daemon_units( ctx, - fsid, + ident, 0, 0, - 'snmp-gateway', - 'daemon_id', c, True, True ) @@ -2562,10 +2553,8 @@ class TestJaeger: _cephadm.create_daemon_dirs(ctx, ident, 0, 0) _cephadm.deploy_daemon_units( ctx, - fsid, + ident, 0, 0, - 'jaeger-collector', - 'daemon_id', c, True, True ) @@ -2584,10 +2573,8 @@ class TestJaeger: _cephadm.create_daemon_dirs(ctx, ident, 0, 0) _cephadm.deploy_daemon_units( ctx, - fsid, + ident, 0, 0, - 'jaeger-collector', - 'daemon_id', c, True, True ) @@ -2606,10 +2593,8 @@ class TestJaeger: _cephadm.create_daemon_dirs(ctx, ident, 0, 0) _cephadm.deploy_daemon_units( ctx, - fsid, + ident, 0, 0, - 'jaeger-agent', - 'daemon_id', c, True, True ) -- 2.39.5