]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: add ContainerDaemonForm
authorJohn Mulligan <jmulligan@redhat.com>
Sat, 23 Sep 2023 19:23:42 +0000 (15:23 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Wed, 4 Oct 2023 19:17:57 +0000 (15:17 -0400)
Add a supplemental DaemonForm subclass that helps deploy container
based daemons in a standard fashion. Most of these methods are
optional and should have sensible defaults.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/cephadmlib/container_daemon_form.py [new file with mode: 0644]

diff --git a/src/cephadm/cephadmlib/container_daemon_form.py b/src/cephadm/cephadmlib/container_daemon_form.py
new file mode 100644 (file)
index 0000000..5aef951
--- /dev/null
@@ -0,0 +1,82 @@
+# container_deamon_form.py - base class for container based daemon forms
+
+import abc
+
+from typing import List, Tuple, Optional
+
+from .container_types import CephContainer, InitContainer
+from .context import CephadmContext
+from .daemon_form import DaemonForm
+from .deploy import DeploymentType
+from .net_utils import EndPoint
+
+
+class ContainerDaemonForm(DaemonForm):
+    """A ContainerDaemonForm is a variety of DaemonForm that runs a
+    single primary daemon process under as a container.
+    It requires that the `container` method be implemented by subclasses.
+    A number of other optional methods may also be overridden.
+    """
+
+    @abc.abstractmethod
+    def container(self, ctx: CephadmContext) -> CephContainer:
+        """Return the CephContainer instance that will be used to build and run
+        the daemon.
+        """
+        raise NotImplementedError()  # pragma: no cover
+
+    @abc.abstractmethod
+    def uid_gid(self, ctx: CephadmContext) -> Tuple[int, int]:
+        """Return a (uid, gid) tuple indicating what UID and GID the daemon is
+        expected to run as. This function is permitted to take complex actions
+        such as running a container to get the needed information.
+        """
+        raise NotImplementedError()  # pragma: no cover
+
+    def init_containers(self, ctx: CephadmContext) -> List[InitContainer]:
+        """Returns a list of init containers to execute prior to the primary
+        container running. By default, returns an empty list.
+        """
+        return []
+
+    def customize_container_binds(self, binds: List[List[str]]) -> None:
+        """Given a list of container binds this function can update, delete,
+        or otherwise mutate the binds that the container will use.
+        """
+        pass
+
+    def customize_container_mounts(self, mounts: List[str]) -> None:
+        """Given a list of container mounts this function can update, delete,
+        or otherwise mutate the mounts that the container will use.
+        """
+        pass
+
+    def customize_container_args(self, args: List[str]) -> None:
+        """Given a list of container arguments this function can update,
+        delete, or otherwise mutate the arguments that the container engine
+        will use.
+        """
+        pass
+
+    def customize_container_endpoints(
+        self, endpoints: List[EndPoint], deployment_type: DeploymentType
+    ) -> None:
+        """Given a list of entrypoints this function can update, delete,
+        or otherwise mutate the entrypoints that the container will use.
+        """
+        pass
+
+    def config_and_keyring(
+        self, ctx: CephadmContext
+    ) -> Tuple[Optional[str], Optional[str]]:
+        """Return a tuple of strings containing the ceph confguration
+        and keyring for the daemon. Returns (None, None) by default.
+        """
+        return None, None
+
+    @property
+    def osd_fsid(self) -> Optional[str]:
+        """Return the OSD FSID or None. Pretty specific to OSDs. You are not
+        expected to understand this.
+        """
+        return None