From 1e531f4854e742091d02d15c8bef7d7e0f70fe61 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Wed, 27 Sep 2023 18:00:03 -0400 Subject: [PATCH] cephadm: convert keepalived type to a ContainerDaemonForm Signed-off-by: John Mulligan --- src/cephadm/cephadm.py | 22 ++++++---------------- src/cephadm/tests/test_ingress.py | 2 +- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index ed6841bbae8..1d5c5536997 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -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() diff --git a/src/cephadm/tests/test_ingress.py b/src/cephadm/tests/test_ingress.py index 798c7370868..51a6e113bc4 100644 --- a/src/cephadm/tests/test_ingress.py +++ b/src/cephadm/tests/test_ingress.py @@ -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 -- 2.39.5