]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: remove direct daemon-type deps from sysctl
authorJohn Mulligan <jmulligan@redhat.com>
Thu, 21 Sep 2023 21:57:43 +0000 (17:57 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Wed, 4 Oct 2023 19:17:57 +0000 (15:17 -0400)
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 <jmulligan@redhat.com>
src/cephadm/cephadm.py

index 665d065c59dc710102bb9574e9e45d8800da048d..7ddad159b6b079143e89c4c30a20a475998c336b 100755 (executable)
@@ -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