From: John Mulligan Date: Sat, 4 Nov 2023 22:19:57 +0000 (-0400) Subject: cephadm: add customize_container_binds method to custom container X-Git-Tag: v19.0.0~110^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=93ad2993bdd4a6701badc729b3e52e93f6ca384a;p=ceph-ci.git cephadm: add customize_container_binds method to custom container Add a customize_container_binds function to the CustomContainer daemon type class and use it from the common get_container_binds function. Signed-off-by: John Mulligan --- diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index d01619cb5af..7d6855778af 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -1854,7 +1854,7 @@ class CustomContainer(ContainerDaemonForm): mounts[source] = destination return mounts - def get_container_binds(self, data_dir: str) -> List[List[str]]: + def _get_container_binds(self, data_dir: str) -> List[List[str]]: """ Get the bind mounts. Relative `source=...` paths will be located below `/var/lib/ceph//`. @@ -1882,6 +1882,12 @@ class CustomContainer(ContainerDaemonForm): data_dir, match.group(1))) return binds + def customize_container_binds( + self, ctx: CephadmContext, binds: List[List[str]] + ) -> None: + data_dir = self.identity.data_dir(ctx.data_dir) + binds.extend(self._get_container_binds(data_dir)) + # Cache the container so we don't need to rebuild it again when calling # into init_containers _container: Optional[CephContainer] = None @@ -2563,9 +2569,8 @@ def get_container_binds( nvmeof = CephNvmeof.create(ctx, ident) nvmeof.customize_container_binds(ctx, binds) elif ident.daemon_type == CustomContainer.daemon_type: - cc = CustomContainer.init(ctx, ident.fsid, ident.daemon_id) - data_dir = ident.data_dir(ctx.data_dir) - binds.extend(cc.get_container_binds(data_dir)) + cc = CustomContainer.create(ctx, ident) + cc.customize_container_binds(ctx, binds) return binds diff --git a/src/cephadm/tests/test_custom_container.py b/src/cephadm/tests/test_custom_container.py index c0f2a7966c4..0c020732cc7 100644 --- a/src/cephadm/tests/test_custom_container.py +++ b/src/cephadm/tests/test_custom_container.py @@ -79,7 +79,10 @@ class TestCustomContainer(unittest.TestCase): }) def test_get_container_binds(self): - result = self.cc.get_container_binds('/xyz') + # TODO: get_container_binds was made private. test the private func for + # now. in the future update to test base class fune + # customize_container_binds + result = self.cc._get_container_binds('/xyz') self.assertEqual(result, [ [ 'type=bind',