mirror of
https://github.com/containers/podman.git
synced 2025-12-10 15:47:46 +08:00
Merge pull request #19805 from vrothberg/fix-19801
kube play: fix pull policy
This commit is contained in:
@@ -33,6 +33,7 @@ import (
|
|||||||
"github.com/containers/podman/v4/pkg/util"
|
"github.com/containers/podman/v4/pkg/util"
|
||||||
"github.com/containers/podman/v4/utils"
|
"github.com/containers/podman/v4/utils"
|
||||||
"github.com/coreos/go-systemd/v22/daemon"
|
"github.com/coreos/go-systemd/v22/daemon"
|
||||||
|
"github.com/docker/distribution/reference"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
"github.com/opencontainers/selinux/go-selinux"
|
"github.com/opencontainers/selinux/go-selinux"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@@ -992,12 +993,7 @@ func (ic *ContainerEngine) getImageAndLabelInfo(ctx context.Context, cwd string,
|
|||||||
}
|
}
|
||||||
pulledImage = i
|
pulledImage = i
|
||||||
} else {
|
} else {
|
||||||
// NOTE: set the pull policy to "newer". This will cover cases
|
pullPolicy := config.PullPolicyMissing
|
||||||
// where the "latest" tag requires a pull and will also
|
|
||||||
// transparently handle "localhost/" prefixed files which *may*
|
|
||||||
// refer to a locally built image OR an image running a
|
|
||||||
// registry on localhost.
|
|
||||||
pullPolicy := config.PullPolicyNewer
|
|
||||||
if len(container.ImagePullPolicy) > 0 {
|
if len(container.ImagePullPolicy) > 0 {
|
||||||
// Make sure to lower the strings since K8s pull policy
|
// Make sure to lower the strings since K8s pull policy
|
||||||
// may be capitalized (see bugzilla.redhat.com/show_bug.cgi?id=1985905).
|
// may be capitalized (see bugzilla.redhat.com/show_bug.cgi?id=1985905).
|
||||||
@@ -1006,6 +1002,14 @@ func (ic *ContainerEngine) getImageAndLabelInfo(ctx context.Context, cwd string,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if named, err := reference.ParseNamed(container.Image); err == nil {
|
||||||
|
tagged, isTagged := named.(reference.NamedTagged)
|
||||||
|
if isTagged && tagged.Tag() == "latest" {
|
||||||
|
// Make sure to always pull the latest image in case it got updated.
|
||||||
|
pullPolicy = config.PullPolicyNewer
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// This ensures the image is the image store
|
// This ensures the image is the image store
|
||||||
pullOptions := &libimage.PullOptions{}
|
pullOptions := &libimage.PullOptions{}
|
||||||
|
|||||||
@@ -764,3 +764,26 @@ EOF
|
|||||||
run_podman pod rm -a
|
run_podman pod rm -a
|
||||||
run_podman rm -a
|
run_podman rm -a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "podman kube play - pull policy" {
|
||||||
|
skip_if_remote "pull debug logs only work locally"
|
||||||
|
|
||||||
|
yaml_source="$PODMAN_TMPDIR/test.yaml"
|
||||||
|
_write_test_yaml command=true
|
||||||
|
|
||||||
|
# Exploit a debug message to make sure the expected pull policy is used
|
||||||
|
run_podman --debug kube play $yaml_source
|
||||||
|
assert "$output" =~ "Pulling image $IMAGE \(policy\: missing\)" "default pull policy is missing"
|
||||||
|
run_podman kube down $yaml_source
|
||||||
|
|
||||||
|
local_image="localhost/name:latest"
|
||||||
|
run_podman tag $IMAGE $local_image
|
||||||
|
rm $yaml_source
|
||||||
|
_write_test_yaml command=true image=$local_image
|
||||||
|
|
||||||
|
run_podman --debug kube play $yaml_source
|
||||||
|
assert "$output" =~ "Pulling image $local_image \(policy\: newer\)" "pull policy is set to newhen pulling latest tag"
|
||||||
|
run_podman kube down $yaml_source
|
||||||
|
|
||||||
|
run_podman rmi $local_image
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user