From bfc2cf087ec8ecd849f4550ab8666cc43f37a234 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sat, 5 Jun 2021 10:05:48 -0500 Subject: [PATCH] cephadm: improve is_container_running() 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 (cherry picked from commit 4757a13dc62d34d3649b1df3bd9f17793c201c1f) --- src/cephadm/cephadm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index de069832ccc3..a7b664cd631e 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -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): -- 2.47.3