From bb0587b8e0bde24d9bbfed7c65e0d351c5f7446b Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Mon, 19 Jul 2021 11:45:54 +0200 Subject: [PATCH] cephadm: Add CephContainer.for_daemon() To avoid calling get_container() Signed-off-by: Sebastian Wagner --- src/cephadm/cephadm | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index c81e9f5bc4d..724977a90fa 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -2554,15 +2554,16 @@ def get_container(ctx: CephadmContext, if ctx.container_engine.version >= CGROUPS_SPLIT_PODMAN_VERSION: container_args.append('--cgroups=split') - return CephContainer( + return CephContainer.for_daemon( ctx, - image=ctx.image, + fsid=fsid, + daemon_type=daemon_type, + daemon_id=str(daemon_id), entrypoint=entrypoint, args=ceph_args + get_daemon_args(ctx, fsid, daemon_type, daemon_id), container_args=container_args, volume_mounts=get_container_mounts(ctx, fsid, daemon_type, daemon_id), bind_mounts=get_container_binds(ctx, fsid, daemon_type, daemon_id), - cname='ceph-%s-%s.%s' % (fsid, daemon_type, daemon_id), envs=envs, privileged=privileged, ptrace=ptrace, @@ -3206,6 +3207,43 @@ class CephContainer: self.memory_request = memory_request self.memory_limit = memory_limit + @classmethod + def for_daemon(cls, + ctx: CephadmContext, + fsid: str, + daemon_type: str, + daemon_id: str, + entrypoint: str, + args: List[str] = [], + volume_mounts: Dict[str, str] = {}, + container_args: List[str] = [], + envs: Optional[List[str]] = None, + privileged: bool = False, + ptrace: bool = False, + bind_mounts: Optional[List[List[str]]] = None, + init: Optional[bool] = None, + host_network: bool = True, + memory_request: Optional[str] = None, + memory_limit: Optional[str] = None, + ) -> 'CephContainer': + return cls( + ctx, + image=ctx.image, + entrypoint=entrypoint, + args=args, + volume_mounts=volume_mounts, + cname='ceph-%s-%s.%s' % (fsid, daemon_type, daemon_id), + container_args=container_args, + envs=envs, + privileged=privileged, + ptrace=ptrace, + bind_mounts=bind_mounts, + init=init, + host_network=host_network, + memory_request=memory_request, + memory_limit=memory_limit, + ) + @property def cname(self) -> str: """ -- 2.39.5