From: Sage Weil Date: Sat, 5 Jun 2021 15:05:48 +0000 (-0500) Subject: cephadm: improve is_container_running() X-Git-Tag: v17.1.0~1725^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=4757a13dc62d34d3649b1df3bd9f17793c201c1f;p=ceph.git 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 --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 7e1df254da6b9..9225ca61072e4 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -2051,10 +2051,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):