Merge pull request #25796 from Luap99/kube-pod-empty

quadlet kube: consider empty pod as running
This commit is contained in:
openshift-merge-bot[bot]
2025-04-08 14:07:42 +00:00
committed by GitHub
2 changed files with 38 additions and 1 deletions

View File

@ -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
}

View File

@ -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 <<EOF
apiVersion: v1
kind: Pod
metadata:
name: $pod_name
EOF
# Create the Quadlet file
local quadlet_file=$PODMAN_TMPDIR/no_cons_$(safename).kube
cat > $quadlet_file <<EOF
[Kube]
Yaml=${yaml_source}
EOF
run_quadlet "$quadlet_file"
service_setup $QUADLET_SERVICE_NAME
run_podman pod ps --format "{{.Name}}--{{.Status}}"
assert "$output" =~ "$pod_name--Running" "pod is running"
service_cleanup $QUADLET_SERVICE_NAME inactive
}
@test "quadlet - image files" {
local quadlet_tmpdir=$PODMAN_TMPDIR/quadlets