Merge pull request #1184 from schnell18/main

Fix service_healthy condition enforcing
This commit is contained in:
Povilas Kanapickas
2025-05-10 14:20:06 +03:00
committed by GitHub
13 changed files with 189 additions and 34 deletions

View File

@@ -2815,6 +2815,18 @@ async def check_dep_conditions(compose: PodmanCompose, deps: set) -> None:
deps_cd = []
for d in deps:
if d.condition == condition:
if (
d.condition
in (ServiceDependencyCondition.HEALTHY, ServiceDependencyCondition.UNHEALTHY)
) and strverscmp_lt(compose.podman_version, "4.6.0"):
log.warning(
"Ignored %s condition check due to podman %s doesn't support %s!",
d.name,
compose.podman_version,
condition.value,
)
continue
deps_cd.extend(compose.container_names_by_service[d.name])
if deps_cd:
@@ -2891,28 +2903,25 @@ async def compose_up(compose: PodmanCompose, args):
.splitlines()
)
diff_hashes = [i for i in hashes if i and i != compose.yaml_hash]
if args.force_recreate or len(diff_hashes):
if (args.force_recreate and len(hashes) > 0) or len(diff_hashes):
log.info("recreating: ...")
down_args = argparse.Namespace(**dict(args.__dict__, volumes=False, rmi=None))
await compose.commands["down"](compose, down_args)
log.info("recreating: done\n\n")
# args.no_recreate disables check for changes (which is not implemented)
podman_command = "run" if args.detach and not args.no_start else "create"
await create_pods(compose, args)
for cnt in compose.containers:
if cnt["_service"] in excluded:
log.debug("** skipping: %s", cnt["name"])
continue
podman_args = await container_to_args(
compose, cnt, detached=args.detach, no_deps=args.no_deps
)
subproc = await compose.podman.run([], podman_command, podman_args)
if podman_command == "run" and subproc is not None:
podman_args = await container_to_args(compose, cnt, detached=False, no_deps=args.no_deps)
subproc = await compose.podman.run([], "create", podman_args)
if not args.no_start and args.detach and subproc is not None:
await run_container(
compose, cnt["name"], deps_from_container(args, cnt), ([], "start", [cnt["name"]])
)
if args.no_start or args.detach or args.dry_run:
return
# TODO: handle already existing