]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: convert keepalived type to a ContainerDaemonForm
authorJohn Mulligan <jmulligan@redhat.com>
Wed, 27 Sep 2023 22:00:03 +0000 (18:00 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Thu, 5 Oct 2023 21:05:33 +0000 (17:05 -0400)
Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/cephadm.py
src/cephadm/tests/test_ingress.py

index ed6841bbae891b575a959572ac94b76901591477..1d5c55369971a01deee38e803954292f4dbd7832 100755 (executable)
@@ -1240,7 +1240,7 @@ class HAproxy(DaemonForm):
 
 
 @register_daemon_form
-class Keepalived(DaemonForm):
+class Keepalived(ContainerDaemonForm):
     """Defines an Keepalived container"""
     daemon_type = 'keepalived'
     required_files = ['keepalived.conf']
@@ -1335,7 +1335,7 @@ class Keepalived(DaemonForm):
             'net.ipv4.ip_nonlocal_bind = 1',
         ]
 
-    def extract_uid_gid_keepalived(self) -> Tuple[int, int]:
+    def uid_gid(self, ctx: CephadmContext) -> Tuple[int, int]:
         # better directory for this?
         return extract_uid_gid(self.ctx, file_path='/var/lib')
 
@@ -1345,6 +1345,10 @@ class Keepalived(DaemonForm):
         mounts[os.path.join(data_dir, 'keepalived.conf')] = '/etc/keepalived/keepalived.conf'
         return mounts
 
+    def container(self, ctx: CephadmContext) -> CephContainer:
+        return get_deployment_container(ctx, self.identity)
+
+
 ##################################
 
 
@@ -5235,20 +5239,6 @@ def _dispatch_deploy(
             endpoints=daemon_endpoints,
         )
 
-    elif daemon_type == Keepalived.daemon_type:
-        keepalived = Keepalived.init(ctx, ident.fsid, ident.daemon_id)
-        uid, gid = keepalived.extract_uid_gid_keepalived()
-        c = get_deployment_container(ctx, ident)
-        deploy_daemon(
-            ctx,
-            ident,
-            c,
-            uid,
-            gid,
-            deployment_type=deployment_type,
-            endpoints=daemon_endpoints,
-        )
-
     elif daemon_type == CephadmAgent.daemon_type:
         # get current user gid and uid
         uid = os.getuid()
index 798c73708686bef6a21a8fd34b9a03d73ba8b4c8..51a6e113bc4a3d14e05637d850f8b7f53a96efb3 100644 (file)
@@ -331,7 +331,7 @@ def test_keepalived_extract_uid_gid_keepalived():
         )
         with mock.patch("cephadm.CephContainer") as cc:
             cc.return_value.run.return_value = "500 500"
-            uid, gid = kad.extract_uid_gid_keepalived()
+            uid, gid = kad.uid_gid(ctx)
             cc.return_value.run.assert_called()
         assert uid == 500
         assert gid == 500