Skip to content

Commit 8d1c373

Browse files
committed
quadlet kube: consider empty pod as running
Since commit 945aade 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: 945aade ("quadlet kube: correctly mark unit as failed") Signed-off-by: Paul Holzinger <[email protected]>
1 parent 0a0d05b commit 8d1c373

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

pkg/domain/infra/abi/play.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,16 @@ func (ic *ContainerEngine) PlayKube(ctx context.Context, body io.Reader, options
287287
setRanContainers := func(r *entities.PlayKubeReport) {
288288
if !ranContainers {
289289
for _, p := range r.Pods {
290+
numCons := len(p.Containers) + len(p.InitContainers)
291+
if numCons == 0 {
292+
// special case, the pod has no containers (besides infra)
293+
// That seems to be valid per https://github.com/containers/podman/issues/25786
294+
// and users could depend on it so mark it as running in that case.
295+
ranContainers = true
296+
break
297+
}
290298
// If the list of container errors is less then the total number of pod containers then we know it did start.
291-
if len(p.ContainerErrors) < len(p.Containers)+len(p.InitContainers) {
299+
if len(p.ContainerErrors) < numCons {
292300
ranContainers = true
293301
break
294302
}

test/system/252-quadlet.bats

+29
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,35 @@ EOF
11601160
kill "$nc_pid"
11611161
}
11621162

1163+
# https://github.com/containers/podman/issues/25786
1164+
@test "quadlet kube - pod without containers" {
1165+
local port=$(random_free_port)
1166+
# Create the YAML file
1167+
pod_name="p-$(safename)"
1168+
yaml_source="$PODMAN_TMPDIR/no_cons_$(safename).yaml"
1169+
cat >$yaml_source <<EOF
1170+
apiVersion: v1
1171+
kind: Pod
1172+
metadata:
1173+
name: $pod_name
1174+
EOF
1175+
1176+
# Create the Quadlet file
1177+
local quadlet_file=$PODMAN_TMPDIR/no_cons_$(safename).kube
1178+
cat > $quadlet_file <<EOF
1179+
[Kube]
1180+
Yaml=${yaml_source}
1181+
EOF
1182+
1183+
run_quadlet "$quadlet_file"
1184+
service_setup $QUADLET_SERVICE_NAME
1185+
1186+
run_podman pod ps --format "{{.Name}}--{{.Status}}"
1187+
assert "$output" =~ "$pod_name--Running" "pod is running"
1188+
1189+
service_cleanup $QUADLET_SERVICE_NAME inactive
1190+
}
1191+
11631192
@test "quadlet - image files" {
11641193
local quadlet_tmpdir=$PODMAN_TMPDIR/quadlets
11651194

0 commit comments

Comments
 (0)