From 14f3cf173846d68ae3d1b3a908b2e5d276544bed Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Thu, 21 Sep 2023 17:57:43 -0400 Subject: [PATCH] cephadm: remove direct daemon-type deps from sysctl Using the appropriate daemon form we can break the direct dependency that the sysctl setup function has on particular classes and use a generic interface. Signed-off-by: John Mulligan --- src/cephadm/cephadm.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index 665d065c59d..7ddad159b6b 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -165,6 +165,8 @@ from cephadmlib.host_facts import HostFacts, list_networks from cephadmlib.ssh import authorize_ssh_key, check_ssh_connectivity from cephadmlib.daemon_form import ( DaemonForm, + SysctlDaemonForm, + create as daemon_form_create, register as register_daemon_form, ) @@ -2955,7 +2957,7 @@ def deploy_daemon_units( f.write(container.image + '\n') # sysctl - install_sysctl(ctx, fsid, daemon_type) + install_sysctl(ctx, fsid, daemon_form_create(ctx, ident)) # systemd install_base_units(ctx, fsid) @@ -3211,7 +3213,7 @@ def update_firewalld(ctx, daemon_type): firewall.apply_rules() -def install_sysctl(ctx: CephadmContext, fsid: str, daemon_type: str) -> None: +def install_sysctl(ctx: CephadmContext, fsid: str, daemon: DaemonForm) -> None: """ Set up sysctl settings """ @@ -3225,17 +3227,13 @@ def install_sysctl(ctx: CephadmContext, fsid: str, daemon_type: str) -> None: with write_new(conf, owner=None, perms=None) as f: f.write('\n'.join(lines)) + if not isinstance(daemon, SysctlDaemonForm): + return + + daemon_type = daemon.identity.daemon_type conf = Path(ctx.sysctl_dir).joinpath(f'90-ceph-{fsid}-{daemon_type}.conf') - lines: List = [] - if daemon_type == 'osd': - lines = OSD.get_sysctl_settings() - elif daemon_type == 'haproxy': - lines = HAproxy.get_sysctl_settings() - elif daemon_type == 'keepalived': - lines = Keepalived.get_sysctl_settings() - elif daemon_type == CephNvmeof.daemon_type: - lines = CephNvmeof.get_sysctl_settings() + lines = daemon.get_sysctl_settings() lines = filter_sysctl_settings(ctx, lines) # apply the sysctl settings -- 2.39.5