Skip to content

Commit e51caab

Browse files
authored
Merge pull request kubernetes#85603 from bart0sh/PR008-kubeadm-dont-check-if-image-exists
kubeadm: don't check if image exists before pulling
2 parents 91aa8df + 7898b3f commit e51caab

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

cmd/kubeadm/app/preflight/checks.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -833,14 +833,6 @@ func (ImagePullCheck) Name() string {
833833
// Check pulls images required by kubeadm. This is a mutating check
834834
func (ipc ImagePullCheck) Check() (warnings, errorList []error) {
835835
for _, image := range ipc.imageList {
836-
ret, err := ipc.runtime.ImageExists(image)
837-
if ret && err == nil {
838-
klog.V(1).Infof("image exists: %s", image)
839-
continue
840-
}
841-
if err != nil {
842-
errorList = append(errorList, errors.Wrapf(err, "failed to check if image %s exists", image))
843-
}
844836
klog.V(1).Infof("pulling %s", image)
845837
if err := ipc.runtime.PullImage(image); err != nil {
846838
errorList = append(errorList, errors.Wrapf(err, "failed to pull image %s", image))

cmd/kubeadm/app/preflight/checks_test.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -753,18 +753,20 @@ func TestSetHasItemOrAll(t *testing.T) {
753753
func TestImagePullCheck(t *testing.T) {
754754
fcmd := fakeexec.FakeCmd{
755755
RunScript: []fakeexec.FakeRunAction{
756-
// Test case 1: img1 and img2 exist, img3 doesn't exist
756+
// Test case 1: pull 3 images successfully
757+
func() ([]byte, []byte, error) { return nil, nil, nil },
757758
func() ([]byte, []byte, error) { return nil, nil, nil },
758759
func() ([]byte, []byte, error) { return nil, nil, nil },
759-
func() ([]byte, []byte, error) { return nil, nil, &fakeexec.FakeExitError{Status: 1} },
760760

761-
// Test case 2: images don't exist
762-
func() ([]byte, []byte, error) { return nil, nil, &fakeexec.FakeExitError{Status: 1} },
761+
// Test case 2: image pull errors
762+
func() ([]byte, []byte, error) { return nil, nil, nil },
763763
func() ([]byte, []byte, error) { return nil, nil, &fakeexec.FakeExitError{Status: 1} },
764764
func() ([]byte, []byte, error) { return nil, nil, &fakeexec.FakeExitError{Status: 1} },
765765
},
766766
CombinedOutputScript: []fakeexec.FakeCombinedOutputAction{
767-
// Test case1: pull only img3
767+
// Test case1: pull 3 images
768+
func() ([]byte, error) { return nil, nil },
769+
func() ([]byte, error) { return nil, nil },
768770
func() ([]byte, error) { return nil, nil },
769771
// Test case 2: fail to pull image2 and image3
770772
func() ([]byte, error) { return nil, nil },
@@ -781,10 +783,6 @@ func TestImagePullCheck(t *testing.T) {
781783
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
782784
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
783785
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
784-
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
785-
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
786-
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
787-
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
788786
},
789787
LookPathFunc: func(cmd string) (string, error) { return "/usr/bin/docker", nil },
790788
}
@@ -803,7 +801,7 @@ func TestImagePullCheck(t *testing.T) {
803801
t.Fatalf("did not expect any warnings but got %q", warnings)
804802
}
805803
if len(errors) != 0 {
806-
t.Fatalf("expected 1 errors but got %d: %q", len(errors), errors)
804+
t.Fatalf("expected 0 errors but got %d: %q", len(errors), errors)
807805
}
808806

809807
warnings, errors = check.Check()

0 commit comments

Comments
 (0)