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:
Dawn Chen 2014-11-14 14:20:29 -08:00
parent 4681918888
commit f729d748ac
2 changed files with 13 additions and 1 deletions

View File

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

View File

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