Merge pull request #3302 from lavalamp/fix

reuse function; never ever unlock without defer
This commit is contained in:
Brendan Burns 2015-01-07 17:25:03 -08:00
commit a19bb1bd29

View File

@ -739,6 +739,9 @@ func (kl *Kubelet) pullImage(img string, ref *api.ObjectReference) error {
} }
return err return err
} }
if ref != nil {
record.Eventf(ref, "waiting", "pulled", "Successfully pulled image %q", img)
}
return nil return nil
} }
@ -905,20 +908,9 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
} }
if api.IsPullAlways(container.ImagePullPolicy) || if api.IsPullAlways(container.ImagePullPolicy) ||
(api.IsPullIfNotPresent(container.ImagePullPolicy) && (!present || latest)) { (api.IsPullIfNotPresent(container.ImagePullPolicy) && (!present || latest)) {
kl.pullLock.RLock() if err := kl.pullImage(container.Image, ref); err != nil {
if err := kl.dockerPuller.Pull(container.Image); err != nil {
if ref != nil {
record.Eventf(ref, "failed", "failed", "Failed to pull image %q", container.Image)
}
glog.Errorf("Failed to pull image %q: %v; skipping pod %q container %q.", container.Image, err, podFullName, container.Name)
kl.pullLock.RUnlock()
continue continue
} }
kl.pullLock.RUnlock()
if ref != nil {
record.Eventf(ref, "waiting", "pulled", "Successfully pulled image %q", container.Image)
}
} }
} }
// TODO(dawnchen): Check RestartPolicy.DelaySeconds before restart a container // TODO(dawnchen): Check RestartPolicy.DelaySeconds before restart a container