]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: use DaemonIdentity in arguments to CephContainer.for_daemon
authorJohn Mulligan <jmulligan@redhat.com>
Tue, 25 Jul 2023 20:23:34 +0000 (16:23 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Mon, 11 Sep 2023 17:34:11 +0000 (13:34 -0400)
Previously, the CephContainer.for_daemon took separate arguments for
fsid, daemon_type, & daemon_id. Now that we have a dedicated type
for encapsulating those values, switch for_daemon to take
a DaemonIdentity instead.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/cephadm.py
src/cephadm/tests/test_cephadm.py

index 0aa28e1ff2fd3540ef0ecf9c41b9fde599a98162..c096b091baba440f8e2f15e5775247a71f5927ba 100755 (executable)
@@ -2741,9 +2741,7 @@ def get_container(ctx: CephadmContext,
 
     return CephContainer.for_daemon(
         ctx,
-        fsid=fsid,
-        daemon_type=daemon_type,
-        daemon_id=str(daemon_id),
+        ident=DaemonIdentity(fsid, daemon_type, daemon_id),
         entrypoint=entrypoint,
         args=ceph_args + get_daemon_args(ctx, fsid, daemon_type, daemon_id),
         container_args=container_args,
@@ -3791,9 +3789,7 @@ class CephContainer(BasicContainer):
     @classmethod
     def for_daemon(cls,
                    ctx: CephadmContext,
-                   fsid: str,
-                   daemon_type: str,
-                   daemon_id: str,
+                   ident: 'DaemonIdentity',
                    entrypoint: str,
                    args: List[str] = [],
                    volume_mounts: Dict[str, str] = {},
@@ -3807,7 +3803,6 @@ class CephContainer(BasicContainer):
                    memory_request: Optional[str] = None,
                    memory_limit: Optional[str] = None,
                    ) -> 'CephContainer':
-        ident = DaemonIdentity(fsid, daemon_type, daemon_id)
         return cls(
             ctx,
             image=ctx.image,
@@ -4356,7 +4351,11 @@ WantedBy=ceph-{fsid}.target
                             'enabled': 'true' if enabled else 'false',
                             'state': state,
                         }
-                        c = CephContainer.for_daemon(self.ctx, self.ctx.fsid, daemon_type, daemon_id, 'bash')
+                        c = CephContainer.for_daemon(
+                            self.ctx,
+                            DaemonIdentity(self.ctx.fsid, daemon_type, daemon_id),
+                            'bash',
+                        )
                         container_id: Optional[str] = None
                         for name in (c.cname, c.old_cname):
                             if name in name_id_mapping:
@@ -5806,7 +5805,8 @@ def get_deployment_type(ctx: CephadmContext, daemon_type: str, daemon_id: str) -
         deployment_type = DeploymentType.RECONFIG
     unit_name = get_unit_name(ctx.fsid, daemon_type, daemon_id)
     (_, state, _) = check_unit(ctx, unit_name)
-    if state == 'running' or is_container_running(ctx, CephContainer.for_daemon(ctx, ctx.fsid, daemon_type, daemon_id, 'bash')):
+    ident = DaemonIdentity(ctx.fsid, daemon_type, daemon_id)
+    if state == 'running' or is_container_running(ctx, CephContainer.for_daemon(ctx, ident, 'bash')):
         # if reconfig was set, that takes priority over redeploy. If
         # this is considered a fresh deployment at this stage,
         # mark it as a redeploy to avoid port checking
@@ -6652,7 +6652,9 @@ def get_daemon_description(ctx, fsid, name, detail=False, legacy_dir=None):
 
 
 def get_container_stats(ctx: CephadmContext, container_path: str, fsid: str, daemon_type: str, daemon_id: str) -> Tuple[str, str, int]:
-    c = CephContainer.for_daemon(ctx, fsid, daemon_type, daemon_id, 'bash')
+    c = CephContainer.for_daemon(
+        ctx, DaemonIdentity(fsid, daemon_type, daemon_id), 'bash'
+    )
     out, err, code = '', '', -1
     for name in (c.cname, c.old_cname):
         cmd = [
index 3543f93d6eb864a1eb8863708a191ccc255a2f50..8ea10bfc81af88aaf4d65adfb97d89f15d35d09a 100644 (file)
@@ -341,9 +341,11 @@ class TestCephAdm(object):
         ]
         _get_container.return_value = _cephadm.CephContainer.for_daemon(
             ctx,
-            fsid='9b9d7609-f4d5-4aba-94c8-effa764d96c9',
-            daemon_type='grafana',
-            daemon_id='host1',
+            ident=_cephadm.DaemonIdentity(
+                fsid='9b9d7609-f4d5-4aba-94c8-effa764d96c9',
+                daemon_type='grafana',
+                daemon_id='host1',
+            ),
             entrypoint='',
             args=[],
             container_args=[],
@@ -396,9 +398,11 @@ class TestCephAdm(object):
 
         _get_deployment_container.return_value = _cephadm.CephContainer.for_daemon(
             ctx,
-            fsid='9b9d7609-f4d5-4aba-94c8-effa764d96c9',
-            daemon_type='mon',
-            daemon_id='test',
+            ident=_cephadm.DaemonIdentity(
+                fsid='9b9d7609-f4d5-4aba-94c8-effa764d96c9',
+                daemon_type='mon',
+                daemon_id='test',
+            ),
             entrypoint='',
             args=[],
             container_args=[],