mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-11 21:12:07 +00:00
Kubelet stop using api/helper.go for PullPolicy
This commit is contained in:
parent
aec4594a8d
commit
3101a33d32
@ -1089,9 +1089,8 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
|
||||
if err != nil {
|
||||
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)
|
||||
latest := dockertools.RequireLatestImage(container.Image)
|
||||
if err != nil {
|
||||
if ref != nil {
|
||||
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)
|
||||
continue
|
||||
}
|
||||
if api.IsPullAlways(container.ImagePullPolicy) ||
|
||||
(api.IsPullIfNotPresent(container.ImagePullPolicy) && (!present || latest)) {
|
||||
if container.ImagePullPolicy == api.PullAlways ||
|
||||
(container.ImagePullPolicy == api.PullIfNotPresent && (!present)) {
|
||||
if err := kl.pullImage(container.Image, ref); err != nil {
|
||||
continue
|
||||
}
|
||||
|
@ -448,7 +448,7 @@ func TestSyncPodsCreatesNetAndContainerPullsImage(t *testing.T) {
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
{Name: "bar"},
|
||||
{Name: "bar", Image: "something", ImagePullPolicy: "PullIfNotPresent"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -463,7 +463,7 @@ func TestSyncPodsCreatesNetAndContainerPullsImage(t *testing.T) {
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
@ -1836,7 +1836,7 @@ func TestSyncPodsWithPullPolicy(t *testing.T) {
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user