]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: convert haproxy type to a ContainerDaemonForm
authorJohn Mulligan <jmulligan@redhat.com>
Wed, 27 Sep 2023 22:06:12 +0000 (18:06 -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 1d5c55369971a01deee38e803954292f4dbd7832..bd116fd00636ee80133b5fc5de609bb3465aa395 100755 (executable)
@@ -1139,7 +1139,7 @@ class CephExporter(DaemonForm):
 
 
 @register_daemon_form
-class HAproxy(DaemonForm):
+class HAproxy(ContainerDaemonForm):
     """Defines an HAproxy container"""
     daemon_type = 'haproxy'
     required_files = ['haproxy.cfg']
@@ -1218,7 +1218,7 @@ class HAproxy(DaemonForm):
             cname = '%s-%s' % (cname, desc)
         return cname
 
-    def extract_uid_gid_haproxy(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')
 
@@ -1236,6 +1236,9 @@ class HAproxy(DaemonForm):
             'net.ipv4.ip_nonlocal_bind = 1',
         ]
 
+    def container(self, ctx: CephadmContext) -> CephContainer:
+        return get_deployment_container(ctx, self.identity)
+
 ##################################
 
 
@@ -5225,19 +5228,6 @@ def _dispatch_deploy(
             deployment_type=deployment_type,
             endpoints=daemon_endpoints,
         )
-    elif daemon_type == HAproxy.daemon_type:
-        haproxy = HAproxy.init(ctx, ident.fsid, ident.daemon_id)
-        uid, gid = haproxy.extract_uid_gid_haproxy()
-        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
index 51a6e113bc4a3d14e05637d850f8b7f53a96efb3..08a9808ddbbaa681c593279a4aa20e2ce9ac27a3 100644 (file)
@@ -168,7 +168,7 @@ def test_haproxy_extract_uid_gid_haproxy():
         )
         with mock.patch("cephadm.CephContainer") as cc:
             cc.return_value.run.return_value = "500 500"
-            uid, gid = hap.extract_uid_gid_haproxy()
+            uid, gid = hap.uid_gid(ctx)
             cc.return_value.run.assert_called()
         assert uid == 500
         assert gid == 500