diff --git a/ops/scripts/check-compose-parity.py b/ops/scripts/check-compose-parity.py index bb932e4..6bbbc66 100755 --- a/ops/scripts/check-compose-parity.py +++ b/ops/scripts/check-compose-parity.py @@ -45,6 +45,16 @@ def live(ct): return out +def image_default(ct, image): + """entrypoint/cmd, которые Docker возьмёт из образа, если compose молчит.""" + r = pct(ct, "docker", "image", "inspect", image, "-f", "{{json .Config.Entrypoint}} {{json .Config.Cmd}}") + try: + ep, cmd = r.stdout.strip().split(" ", 1) + return json.loads(ep), json.loads(cmd) + except Exception: + return None, None + + def wanted(ct): p = f"{REPO}/deploy/ct{ct}/docker-compose.yml" if not os.path.exists(p): @@ -75,9 +85,17 @@ def main(): print(f"{name}: контейнера нет (будет создан)") continue for field in ("image", "entrypoint", "cmd"): - if w.get(field) != l.get(field): - print(f"{name}.{field}: compose={w.get(field)} живой={l.get(field)}") - problems += 1 + wv, lv = w.get(field), l.get(field) + if wv == lv: + continue + if wv is None: + # compose не переопределяет — значит действует значение образа + ep, cmd = image_default(ct, w.get("image") or lv and l.get("image")) + default = ep if field == "entrypoint" else cmd + if lv == default: + continue + print(f"{name}.{field}: compose={wv} живой={lv}") + problems += 1 if w.get("env") and l.get("env"): missing = set(w["env"]) - set(l["env"]) if missing: