Merge pull request #74399 from RA489/runpullimagescleanup

Rename RunPullImagesCheck to PullControlPlaneImages
This commit is contained in:
Kubernetes Prow Robot 2019-03-27 16:01:03 -07:00 committed by GitHub
commit 7131617d0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 16 deletions

View File

@ -423,8 +423,7 @@ func NewCmdConfigImagesPull() *cobra.Command {
kubeadmutil.CheckErr(err) kubeadmutil.CheckErr(err)
containerRuntime, err := utilruntime.NewContainerRuntime(utilsexec.New(), internalcfg.NodeRegistration.CRISocket) containerRuntime, err := utilruntime.NewContainerRuntime(utilsexec.New(), internalcfg.NodeRegistration.CRISocket)
kubeadmutil.CheckErr(err) kubeadmutil.CheckErr(err)
imagesPull := NewImagesPull(containerRuntime, images.GetAllImages(&internalcfg.ClusterConfiguration)) PullControlPlaneImages(containerRuntime, &internalcfg.ClusterConfiguration)
kubeadmutil.CheckErr(imagesPull.PullAll())
}, },
} }
AddImagesCommonConfigFlags(cmd.PersistentFlags(), externalcfg, &cfgPath, &featureGatesString) AddImagesCommonConfigFlags(cmd.PersistentFlags(), externalcfg, &cfgPath, &featureGatesString)
@ -447,10 +446,11 @@ func NewImagesPull(runtime utilruntime.ContainerRuntime, images []string) *Image
} }
} }
// PullAll pulls all images that the ImagesPull knows about // PullControlPlaneImages pulls all images that the ImagesPull knows about
func (ip *ImagesPull) PullAll() error { func PullControlPlaneImages(runtime utilruntime.ContainerRuntime, cfg *kubeadmapi.ClusterConfiguration) error {
for _, image := range ip.images { images := images.GetControlPlaneImages(cfg)
if err := ip.runtime.PullImage(image); err != nil { for _, image := range images {
if err := runtime.PullImage(image); err != nil {
return errors.Wrapf(err, "failed to pull image %q", image) return errors.Wrapf(err, "failed to pull image %q", image)
} }
fmt.Printf("[config/images] Pulled %s\n", image) fmt.Printf("[config/images] Pulled %s\n", image)
@ -505,7 +505,7 @@ type ImagesList struct {
// Run runs the images command and writes the result to the io.Writer passed in // Run runs the images command and writes the result to the io.Writer passed in
func (i *ImagesList) Run(out io.Writer) error { func (i *ImagesList) Run(out io.Writer) error {
imgs := images.GetAllImages(&i.cfg.ClusterConfiguration) imgs := images.GetControlPlaneImages(&i.cfg.ClusterConfiguration)
for _, img := range imgs { for _, img := range imgs {
fmt.Fprintln(out, img) fmt.Fprintln(out, img)
} }

View File

@ -244,12 +244,12 @@ func TestImagesPull(t *testing.T) {
} }
images := []string{"a", "b", "c", "d", "a"} images := []string{"a", "b", "c", "d", "a"}
ip := NewImagesPull(containerRuntime, images) for _, image := range images {
if err := containerRuntime.PullImage(image); err != nil {
err = ip.PullAll()
if err != nil {
t.Fatalf("expected nil but found %v", err) t.Fatalf("expected nil but found %v", err)
} }
fmt.Printf("[config/images] Pulled %s\n", image)
}
if fcmd.CombinedOutputCalls != len(images) { if fcmd.CombinedOutputCalls != len(images) {
t.Errorf("expected %d calls, got %d", len(images), fcmd.CombinedOutputCalls) t.Errorf("expected %d calls, got %d", len(images), fcmd.CombinedOutputCalls)

View File

@ -85,8 +85,8 @@ func GetPauseImage(cfg *kubeadmapi.ClusterConfiguration) string {
return GetGenericImage(cfg.ImageRepository, "pause", constants.PauseVersion) return GetGenericImage(cfg.ImageRepository, "pause", constants.PauseVersion)
} }
// GetAllImages returns a list of container images kubeadm expects to use on a control plane node // GetControlPlaneImages returns a list of container images kubeadm expects to use on a control plane node
func GetAllImages(cfg *kubeadmapi.ClusterConfiguration) []string { func GetControlPlaneImages(cfg *kubeadmapi.ClusterConfiguration) []string {
imgs := []string{} imgs := []string{}
// start with core kubernetes images // start with core kubernetes images

View File

@ -254,7 +254,7 @@ func TestGetAllImages(t *testing.T) {
} }
for _, tc := range testcases { for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
imgs := GetAllImages(tc.cfg) imgs := GetControlPlaneImages(tc.cfg)
for _, img := range imgs { for _, img := range imgs {
if strings.Contains(img, tc.expect) { if strings.Contains(img, tc.expect) {
return return

View File

@ -1074,7 +1074,7 @@ func RunPullImagesCheck(execer utilsexec.Interface, cfg *kubeadmapi.InitConfigur
} }
checks := []Checker{ checks := []Checker{
ImagePullCheck{runtime: containerRuntime, imageList: images.GetAllImages(&cfg.ClusterConfiguration)}, ImagePullCheck{runtime: containerRuntime, imageList: images.GetControlPlaneImages(&cfg.ClusterConfiguration)},
} }
return RunChecks(checks, os.Stderr, ignorePreflightErrors) return RunChecks(checks, os.Stderr, ignorePreflightErrors)
} }