]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: exec: also search for old cname
authorSebastian Wagner <sewagner@redhat.com>
Wed, 14 Jul 2021 13:15:50 +0000 (15:15 +0200)
committerSebastian Wagner <sewagner@redhat.com>
Wed, 4 Aug 2021 12:52:55 +0000 (14:52 +0200)
Signed-off-by: Sebastian Wagner <sewagner@redhat.com>
src/cephadm/cephadm

index 85d39dd44907b8adf7dff09e897a3ea4569eb173..cd42a32637d2c92e3cbeae853217e09bb772b88a 100755 (executable)
@@ -2079,14 +2079,18 @@ def check_units(ctx, units, enabler=None):
 
 
 def is_container_running(ctx: CephadmContext, c: 'CephContainer') -> bool:
+    return bool(get_running_container_name(ctx, c))
+
+
+def get_running_container_name(ctx: CephadmContext, c: 'CephContainer') -> Optional[str]:
     for name in [c.cname, c.old_cname]:
         out, err, ret = call(ctx, [
             ctx.container_engine.path, 'container', 'inspect',
             '--format', '{{.State.Status}}', name
         ])
         if out == 'running':
-            return True
-    return False
+            return name
+    return None
 
 
 def get_legacy_config_fsid(cluster, legacy_dir=None):
@@ -3384,6 +3388,9 @@ class CephContainer:
 
     def exec_cmd(self, cmd):
         # type: (List[str]) -> List[str]
+        cname = get_running_container_name(self.ctx, self)
+        if not cname:
+            raise Error('unable to find container "{}"'.format(self.cname))
         return [
             str(self.ctx.container_engine.path),
             'exec',