]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: move option for setting unlimited pids into engine classes
authorJohn Mulligan <jmulligan@redhat.com>
Sat, 21 Oct 2023 15:41:15 +0000 (11:41 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Mon, 6 Nov 2023 16:03:40 +0000 (11:03 -0500)
Move the option for setting unlimited pids for the container engine
into the container engine classes. This continues the attempts to
improve the locality of items specific to certain classes to be
by making them part of the classes.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/cephadm.py
src/cephadm/cephadmlib/container_engine_base.py
src/cephadm/cephadmlib/container_engines.py
src/cephadm/tests/fixtures.py

index 641b269c1324d7b0bb114f27b640bbc6e641db73..650e080843ede8c0436c4e2dca9888e60ae48eef 100755 (executable)
@@ -70,7 +70,6 @@ from cephadmlib.constants import (
     LOGROTATE_DIR,
     LOG_DIR,
     LOG_DIR_MODE,
-    PIDS_LIMIT_UNLIMITED_PODMAN_VERSION,
     SYSCTL_DIR,
     UNIT_DIR,
 )
@@ -2692,13 +2691,7 @@ def _update_pids_limit(ctx: CephadmContext, daemon_type: str, container_args: Li
     unlimited_daemons.add(NFSGanesha.daemon_type)
     if daemon_type not in unlimited_daemons:
         return
-    if (
-        isinstance(ctx.container_engine, Podman)
-        and ctx.container_engine.version >= PIDS_LIMIT_UNLIMITED_PODMAN_VERSION
-    ):
-        container_args.append('--pids-limit=-1')
-    else:
-        container_args.append('--pids-limit=0')
+    container_args.append(ctx.container_engine.unlimited_pids_option)
 
 
 def get_container(
index 135b2f4f3210561bf1be3c55a50719b1389cd5a9..c8d4bfbcf29059fc724fc59678382d4818391170 100644 (file)
@@ -11,5 +11,12 @@ class ContainerEngine:
     def EXE(self) -> str:
         raise NotImplementedError()
 
+    @property
+    def unlimited_pids_option(self) -> str:
+        """The option to pass to the container engine for allowing unlimited
+        pids (processes).
+        """
+        return '--pids-limit=0'
+
     def __str__(self) -> str:
         return f'{self.EXE} ({self.path})'
index 8ced8ab3ff4b430131045d14ebb3d23479631646..98019fa820b3a9cfac882f5dabab7e05150e9d67 100644 (file)
@@ -11,6 +11,7 @@ from .constants import (
     CGROUPS_SPLIT_PODMAN_VERSION,
     DEFAULT_MODE,
     MIN_PODMAN_VERSION,
+    PIDS_LIMIT_UNLIMITED_PODMAN_VERSION,
 )
 from .exceptions import Error
 
@@ -45,6 +46,15 @@ class Podman(ContainerEngine):
         """Return true if this version of podman supports split cgroups."""
         return self.version >= CGROUPS_SPLIT_PODMAN_VERSION
 
+    @property
+    def unlimited_pids_option(self) -> str:
+        """The option to pass to the container engine for allowing unlimited
+        pids (processes).
+        """
+        if self.version >= PIDS_LIMIT_UNLIMITED_PODMAN_VERSION:
+            return '--pids-limit=-1'
+        return '--pids-limit=0'
+
     def service_args(
         self, ctx: CephadmContext, service_name: str
     ) -> List[str]:
index 86a8c6119ea8a4d27f70f1a2627873af4d3e556b..d25dffa9e3b44cbfc66ac9b1164554046174ddd3 100644 (file)
@@ -21,6 +21,7 @@ def mock_docker():
 
     docker = mock.Mock(Docker)
     docker.path = '/usr/bin/docker'
+    type(docker).unlimited_pids_option = Docker.unlimited_pids_option
     return docker
 
 
@@ -37,6 +38,7 @@ def mock_podman():
     # https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock
     type(podman).supports_split_cgroups = Podman.supports_split_cgroups
     type(podman).service_args = Podman.service_args
+    type(podman).unlimited_pids_option = Podman.unlimited_pids_option
     return podman