Kubelet stop using api/helper.go for PullPolicy

This commit is contained in:
Dawn Chen 2015-01-16 16:55:19 -08:00
parent aec4594a8d
commit 3101a33d32
2 changed files with 6 additions and 7 deletions

View File

@ -1089,9 +1089,8 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
if err != nil { if err != nil {
glog.Errorf("Couldn't make a ref to pod %v, container %v: '%v'", pod.Name, container.Name, err) glog.Errorf("Couldn't make a ref to pod %v, container %v: '%v'", pod.Name, container.Name, err)
} }
if !api.IsPullNever(container.ImagePullPolicy) { if container.ImagePullPolicy != api.PullNever {
present, err := kl.dockerPuller.IsImagePresent(container.Image) present, err := kl.dockerPuller.IsImagePresent(container.Image)
latest := dockertools.RequireLatestImage(container.Image)
if err != nil { if err != nil {
if ref != nil { if ref != nil {
record.Eventf(ref, "failed", "Failed to inspect image %q", container.Image) record.Eventf(ref, "failed", "Failed to inspect image %q", container.Image)
@ -1099,8 +1098,8 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
glog.Errorf("Failed to inspect image %q: %v; skipping pod %q container %q", container.Image, err, podFullName, container.Name) glog.Errorf("Failed to inspect image %q: %v; skipping pod %q container %q", container.Image, err, podFullName, container.Name)
continue continue
} }
if api.IsPullAlways(container.ImagePullPolicy) || if container.ImagePullPolicy == api.PullAlways ||
(api.IsPullIfNotPresent(container.ImagePullPolicy) && (!present || latest)) { (container.ImagePullPolicy == api.PullIfNotPresent && (!present)) {
if err := kl.pullImage(container.Image, ref); err != nil { if err := kl.pullImage(container.Image, ref); err != nil {
continue continue
} }

View File

@ -448,7 +448,7 @@ func TestSyncPodsCreatesNetAndContainerPullsImage(t *testing.T) {
}, },
Spec: api.PodSpec{ Spec: api.PodSpec{
Containers: []api.Container{ Containers: []api.Container{
{Name: "bar"}, {Name: "bar", Image: "something", ImagePullPolicy: "PullIfNotPresent"},
}, },
}, },
}, },
@ -463,7 +463,7 @@ func TestSyncPodsCreatesNetAndContainerPullsImage(t *testing.T) {
fakeDocker.Lock() fakeDocker.Lock()
if !reflect.DeepEqual(puller.ImagesPulled, []string{"custom_image_name", ""}) { if !reflect.DeepEqual(puller.ImagesPulled, []string{"custom_image_name", "something"}) {
t.Errorf("Unexpected pulled containers: %v", puller.ImagesPulled) t.Errorf("Unexpected pulled containers: %v", puller.ImagesPulled)
} }
@ -1836,7 +1836,7 @@ func TestSyncPodsWithPullPolicy(t *testing.T) {
fakeDocker.Lock() fakeDocker.Lock()
if !reflect.DeepEqual(puller.ImagesPulled, []string{"custom_image_name", "pull_always_image", "pull_if_not_present_image", "want:latest"}) { if !reflect.DeepEqual(puller.ImagesPulled, []string{"custom_image_name", "pull_always_image", "pull_if_not_present_image"}) {
t.Errorf("Unexpected pulled containers: %v", puller.ImagesPulled) t.Errorf("Unexpected pulled containers: %v", puller.ImagesPulled)
} }