mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 04:06:03 +00:00
If the image with :latest tag specified in Spec, kubelet should try
to pull the latest one even the policy is PullIfNotPresent.
This commit is contained in:
parent
4681918888
commit
f729d748ac
@ -247,6 +247,16 @@ func (p dockerPuller) IsImagePresent(name string) (bool, error) {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// RequireLatestImage returns if the user wants the latest image
|
||||
func RequireLatestImage(name string) bool {
|
||||
_, tag := parseImageName(name)
|
||||
|
||||
if tag == "latest" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (p throttledDockerPuller) IsImagePresent(name string) (bool, error) {
|
||||
return p.puller.IsImagePresent(name)
|
||||
}
|
||||
|
@ -714,11 +714,13 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
|
||||
glog.V(3).Infof("Container with name %s--%s--%s doesn't exist, creating %#v", podFullName, uuid, container.Name, container)
|
||||
if !api.IsPullNever(container.ImagePullPolicy) {
|
||||
present, err := kl.dockerPuller.IsImagePresent(container.Image)
|
||||
latest := dockertools.RequireLatestImage(container.Image)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to inspect image: %s: %#v skipping pod %s container %s", container.Image, err, podFullName, container.Name)
|
||||
continue
|
||||
}
|
||||
if api.IsPullAlways(container.ImagePullPolicy) || !present {
|
||||
if api.IsPullAlways(container.ImagePullPolicy) ||
|
||||
(api.IsPullIfNotPresent(container.ImagePullPolicy) && (!present || latest)) {
|
||||
if err := kl.dockerPuller.Pull(container.Image); err != nil {
|
||||
glog.Errorf("Failed to pull image %s: %v skipping pod %s container %s.", container.Image, err, podFullName, container.Name)
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user