From aaffe62c0b224039db6c70097b7122e0ad72013a Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Wed, 27 Sep 2023 18:06:12 -0400 Subject: [PATCH] cephadm: convert haproxy type to a ContainerDaemonForm Signed-off-by: John Mulligan --- src/cephadm/cephadm.py | 20 +++++--------------- src/cephadm/tests/test_ingress.py | 2 +- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index 1d5c55369971a..bd116fd00636e 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -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 diff --git a/src/cephadm/tests/test_ingress.py b/src/cephadm/tests/test_ingress.py index 51a6e113bc4a3..08a9808ddbbaa 100644 --- a/src/cephadm/tests/test_ingress.py +++ b/src/cephadm/tests/test_ingress.py @@ -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 -- 2.39.5