mirror of https://github.com/containers/podman.git
kube play: always pull when both imagePullPolicy and tag are missing
Align the behaviour of `podman kube play file.yaml` to Kubernetes' by forcing an image pull when `imagePullPolicy` is omitted and the container image does not specify a tag. Signed-off-by: Maurizio Porrato <mporrato@redhat.com>
This commit is contained in:
parent
11c37d5c95
commit
cb81da9bee
|
@ -1050,7 +1050,7 @@ func (ic *ContainerEngine) getImageAndLabelInfo(ctx context.Context, cwd string,
|
||||||
} else {
|
} else {
|
||||||
if named, err := reference.ParseNamed(container.Image); err == nil {
|
if named, err := reference.ParseNamed(container.Image); err == nil {
|
||||||
tagged, isTagged := named.(reference.NamedTagged)
|
tagged, isTagged := named.(reference.NamedTagged)
|
||||||
if isTagged && tagged.Tag() == "latest" {
|
if !isTagged || tagged.Tag() == "latest" {
|
||||||
// Make sure to always pull the latest image in case it got updated.
|
// Make sure to always pull the latest image in case it got updated.
|
||||||
pullPolicy = config.PullPolicyNewer
|
pullPolicy = config.PullPolicyNewer
|
||||||
}
|
}
|
||||||
|
|
|
@ -3163,6 +3163,46 @@ var _ = Describe("Podman kube play", func() {
|
||||||
Expect(oldBBinspect[0].Digest).To(Not(Equal(newBBinspect[0].Digest)))
|
Expect(oldBBinspect[0].Digest).To(Not(Equal(newBBinspect[0].Digest)))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("with no tag and no pull policy should always pull", func() {
|
||||||
|
oldBB := "quay.io/libpod/busybox:1.30.1"
|
||||||
|
pull := podmanTest.Podman([]string{"pull", oldBB})
|
||||||
|
pull.WaitWithDefaultTimeout()
|
||||||
|
Expect(pull).Should(Exit(0))
|
||||||
|
|
||||||
|
tag := podmanTest.Podman([]string{"tag", oldBB, BB})
|
||||||
|
tag.WaitWithDefaultTimeout()
|
||||||
|
Expect(tag).Should(ExitCleanly())
|
||||||
|
|
||||||
|
rmi := podmanTest.Podman([]string{"rmi", oldBB})
|
||||||
|
rmi.WaitWithDefaultTimeout()
|
||||||
|
Expect(rmi).Should(ExitCleanly())
|
||||||
|
|
||||||
|
inspect := podmanTest.Podman([]string{"inspect", BB})
|
||||||
|
inspect.WaitWithDefaultTimeout()
|
||||||
|
Expect(inspect).Should(ExitCleanly())
|
||||||
|
oldBBinspect := inspect.InspectImageJSON()
|
||||||
|
|
||||||
|
noTagBB := "quay.io/libpod/busybox"
|
||||||
|
ctr := getCtr(withImage(noTagBB), withPullPolicy(""))
|
||||||
|
err := generateKubeYaml("pod", getPod(withCtr(ctr)), kubeYaml)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
kube := podmanTest.Podman([]string{"kube", "play", kubeYaml})
|
||||||
|
kube.WaitWithDefaultTimeout()
|
||||||
|
Expect(kube).Should(Exit(0))
|
||||||
|
if IsRemote() {
|
||||||
|
Expect(kube.ErrorToString()).To(BeEmpty())
|
||||||
|
} else {
|
||||||
|
Expect(kube.ErrorToString()).To(ContainSubstring("Copying blob "))
|
||||||
|
}
|
||||||
|
|
||||||
|
inspect = podmanTest.Podman([]string{"inspect", noTagBB})
|
||||||
|
inspect.WaitWithDefaultTimeout()
|
||||||
|
Expect(inspect).Should(ExitCleanly())
|
||||||
|
newBBinspect := inspect.InspectImageJSON()
|
||||||
|
Expect(oldBBinspect[0].Digest).To(Not(Equal(newBBinspect[0].Digest)))
|
||||||
|
})
|
||||||
|
|
||||||
It("with image data", func() {
|
It("with image data", func() {
|
||||||
testyaml := `
|
testyaml := `
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
|
|
Loading…
Reference in New Issue