From 8d1c373475b900b9e0ccc7b4827e4ac283328849 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Fri, 4 Apr 2025 18:28:36 +0200 Subject: [PATCH] quadlet kube: consider empty pod as running Since commit 945aade38b we do tear down the kube units if all pods failed to start. This however broke the use case of an empty pod as we did not consider that being starting successfully which is wrong and caused a regression for at least one user. To fix this special case the empty pod and consider that running. Fixes: #25786 Fixes: 945aade38b ("quadlet kube: correctly mark unit as failed") Signed-off-by: Paul Holzinger --- pkg/domain/infra/abi/play.go | 10 +++++++++- test/system/252-quadlet.bats | 29 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go index 12558cbdb7..6ba84cf67b 100644 --- a/pkg/domain/infra/abi/play.go +++ b/pkg/domain/infra/abi/play.go @@ -287,8 +287,16 @@ func (ic *ContainerEngine) PlayKube(ctx context.Context, body io.Reader, options setRanContainers := func(r *entities.PlayKubeReport) { if !ranContainers { for _, p := range r.Pods { + numCons := len(p.Containers) + len(p.InitContainers) + if numCons == 0 { + // special case, the pod has no containers (besides infra) + // That seems to be valid per https://github.com/containers/podman/issues/25786 + // and users could depend on it so mark it as running in that case. + ranContainers = true + break + } // If the list of container errors is less then the total number of pod containers then we know it did start. - if len(p.ContainerErrors) < len(p.Containers)+len(p.InitContainers) { + if len(p.ContainerErrors) < numCons { ranContainers = true break } diff --git a/test/system/252-quadlet.bats b/test/system/252-quadlet.bats index 10de6882cb..8b4952c330 100644 --- a/test/system/252-quadlet.bats +++ b/test/system/252-quadlet.bats @@ -1160,6 +1160,35 @@ EOF kill "$nc_pid" } +# https://github.com/containers/podman/issues/25786 +@test "quadlet kube - pod without containers" { + local port=$(random_free_port) + # Create the YAML file + pod_name="p-$(safename)" + yaml_source="$PODMAN_TMPDIR/no_cons_$(safename).yaml" + cat >$yaml_source < $quadlet_file <