Skip to content

Commit 7131617

Browse files
authored
Merge pull request kubernetes#74399 from RA489/runpullimagescleanup
Rename RunPullImagesCheck to PullControlPlaneImages
2 parents b9dbb45 + 8bcc82a commit 7131617

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

cmd/kubeadm/app/cmd/config.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,7 @@ func NewCmdConfigImagesPull() *cobra.Command {
423423
kubeadmutil.CheckErr(err)
424424
containerRuntime, err := utilruntime.NewContainerRuntime(utilsexec.New(), internalcfg.NodeRegistration.CRISocket)
425425
kubeadmutil.CheckErr(err)
426-
imagesPull := NewImagesPull(containerRuntime, images.GetAllImages(&internalcfg.ClusterConfiguration))
427-
kubeadmutil.CheckErr(imagesPull.PullAll())
426+
PullControlPlaneImages(containerRuntime, &internalcfg.ClusterConfiguration)
428427
},
429428
}
430429
AddImagesCommonConfigFlags(cmd.PersistentFlags(), externalcfg, &cfgPath, &featureGatesString)
@@ -447,10 +446,11 @@ func NewImagesPull(runtime utilruntime.ContainerRuntime, images []string) *Image
447446
}
448447
}
449448

450-
// PullAll pulls all images that the ImagesPull knows about
451-
func (ip *ImagesPull) PullAll() error {
452-
for _, image := range ip.images {
453-
if err := ip.runtime.PullImage(image); err != nil {
449+
// PullControlPlaneImages pulls all images that the ImagesPull knows about
450+
func PullControlPlaneImages(runtime utilruntime.ContainerRuntime, cfg *kubeadmapi.ClusterConfiguration) error {
451+
images := images.GetControlPlaneImages(cfg)
452+
for _, image := range images {
453+
if err := runtime.PullImage(image); err != nil {
454454
return errors.Wrapf(err, "failed to pull image %q", image)
455455
}
456456
fmt.Printf("[config/images] Pulled %s\n", image)
@@ -505,7 +505,7 @@ type ImagesList struct {
505505

506506
// Run runs the images command and writes the result to the io.Writer passed in
507507
func (i *ImagesList) Run(out io.Writer) error {
508-
imgs := images.GetAllImages(&i.cfg.ClusterConfiguration)
508+
imgs := images.GetControlPlaneImages(&i.cfg.ClusterConfiguration)
509509
for _, img := range imgs {
510510
fmt.Fprintln(out, img)
511511
}

cmd/kubeadm/app/cmd/config_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ func TestImagesPull(t *testing.T) {
244244
}
245245

246246
images := []string{"a", "b", "c", "d", "a"}
247-
ip := NewImagesPull(containerRuntime, images)
248-
249-
err = ip.PullAll()
250-
if err != nil {
251-
t.Fatalf("expected nil but found %v", err)
247+
for _, image := range images {
248+
if err := containerRuntime.PullImage(image); err != nil {
249+
t.Fatalf("expected nil but found %v", err)
250+
}
251+
fmt.Printf("[config/images] Pulled %s\n", image)
252252
}
253253

254254
if fcmd.CombinedOutputCalls != len(images) {

cmd/kubeadm/app/images/images.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ func GetPauseImage(cfg *kubeadmapi.ClusterConfiguration) string {
8585
return GetGenericImage(cfg.ImageRepository, "pause", constants.PauseVersion)
8686
}
8787

88-
// GetAllImages returns a list of container images kubeadm expects to use on a control plane node
89-
func GetAllImages(cfg *kubeadmapi.ClusterConfiguration) []string {
88+
// GetControlPlaneImages returns a list of container images kubeadm expects to use on a control plane node
89+
func GetControlPlaneImages(cfg *kubeadmapi.ClusterConfiguration) []string {
9090
imgs := []string{}
9191

9292
// start with core kubernetes images

cmd/kubeadm/app/images/images_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ func TestGetAllImages(t *testing.T) {
254254
}
255255
for _, tc := range testcases {
256256
t.Run(tc.name, func(t *testing.T) {
257-
imgs := GetAllImages(tc.cfg)
257+
imgs := GetControlPlaneImages(tc.cfg)
258258
for _, img := range imgs {
259259
if strings.Contains(img, tc.expect) {
260260
return

cmd/kubeadm/app/preflight/checks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ func RunPullImagesCheck(execer utilsexec.Interface, cfg *kubeadmapi.InitConfigur
10741074
}
10751075

10761076
checks := []Checker{
1077-
ImagePullCheck{runtime: containerRuntime, imageList: images.GetAllImages(&cfg.ClusterConfiguration)},
1077+
ImagePullCheck{runtime: containerRuntime, imageList: images.GetControlPlaneImages(&cfg.ClusterConfiguration)},
10781078
}
10791079
return RunChecks(checks, os.Stderr, ignorePreflightErrors)
10801080
}

0 commit comments

Comments
 (0)