]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: improve is_container_running() 41684/head
authorSage Weil <sage@newdream.net>
Sat, 5 Jun 2021 15:05:48 +0000 (10:05 -0500)
committerSage Weil <sage@newdream.net>
Mon, 7 Jun 2021 14:10:43 +0000 (09:10 -0500)
The 'podman ps' command sporatically exits with 125, I suspect due
to some race/bug in podman itself.

However, our goal here is just to check if a specific container
is running.  Use inspect for that instead--it's even (a bit) faster.

Fixes: https://tracker.ceph.com/issues/51109
Signed-off-by: Sage Weil <sage@newdream.net>
(cherry picked from commit 4757a13dc62d34d3649b1df3bd9f17793c201c1f)

src/cephadm/cephadm

index de069832ccc34049aab8775d8a358e423f3cbab6..a7b664cd631e1d1820b5a07cd48612edb02d6684 100755 (executable)
@@ -2050,10 +2050,11 @@ def check_units(ctx, units, enabler=None):
 
 
 def is_container_running(ctx: CephadmContext, name: str) -> bool:
-    out, err, ret = call_throws(ctx, [
-        ctx.container_engine.path, 'ps',
-        '--format', '{{.Names}}'])
-    return name in out
+    out, err, ret = call(ctx, [
+        ctx.container_engine.path, 'container', 'inspect',
+        '--format', '{{.State.Status}}', name
+    ])
+    return out == 'running'
 
 
 def get_legacy_config_fsid(cluster, legacy_dir=None):