]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: add customize_container_binds method to custom container
authorJohn Mulligan <jmulligan@redhat.com>
Sat, 4 Nov 2023 22:19:57 +0000 (18:19 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Thu, 9 Nov 2023 19:50:46 +0000 (14:50 -0500)
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 <jmulligan@redhat.com>
src/cephadm/cephadm.py
src/cephadm/tests/test_custom_container.py

index d01619cb5aff29d67b40c911326ed1c8ddaa8955..7d6855778afae6939405a2fc71a86f25e9578b2d 100755 (executable)
@@ -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/<cluster-fsid>/<daemon-name>`.
@@ -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
 
index c0f2a7966c44c2bcf30fc32ab2825ef1fdefd666..0c020732cc7d559f38001ea506957412751e9965 100644 (file)
@@ -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',