fix: ensure infra image is set from infra container spec in PodConfigToSpec

fixes #21609

Signed-off-by: Nabil Houidi <35373676+NabilHouidi@users.noreply.github.com>
This commit is contained in:
Nabil Houidi 2026-03-26 11:46:35 +01:00
parent d66f0856a8
commit d44655537e
No known key found for this signature in database
GPG key ID: BAD8C44B89DBEC44
2 changed files with 14 additions and 3 deletions

View file

@ -356,14 +356,15 @@ func PodConfigToSpec(rt *libpod.Runtime, spec *specgen.PodSpecGenerator, infraOp
return nil, err
}
if len(spec.InfraContainerSpec.Image) > 0 {
spec.InfraImage = spec.InfraContainerSpec.Image
}
spec.Name = name
}
// need to reset hostname, name etc of both pod and infra
spec.Hostname = ""
if len(spec.InfraContainerSpec.Image) > 0 {
spec.InfraImage = spec.InfraContainerSpec.Image
}
return pod, nil
}

View file

@ -57,4 +57,14 @@ var _ = Describe("Podman generate spec", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
})
It("generate spec for pod with no infra container", func() {
session := podmanTest.Podman([]string{"pod", "create", "--share", "none", "--name", "podspecgen2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"generate", "spec", "--compact", "podspecgen2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
})
})