From e08988ba16ad78046a24a2609ca3e126dd933afb Mon Sep 17 00:00:00 2001 From: Shiming Zhang Date: Sun, 31 Jan 2021 19:51:16 +0800 Subject: [PATCH] Fix pull empty image URL Signed-off-by: Shiming Zhang --- test/e2e_node/image_list.go | 41 +++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/test/e2e_node/image_list.go b/test/e2e_node/image_list.go index 16c6240362a..c604f68c20a 100644 --- a/test/e2e_node/image_list.go +++ b/test/e2e_node/image_list.go @@ -60,7 +60,6 @@ var NodePrePullImageList = sets.NewString( imageutils.GetE2EImage(imageutils.Perl), imageutils.GetE2EImage(imageutils.Nonewprivs), imageutils.GetPauseImageName(), - getGPUDevicePluginImage(), imageutils.GetE2EImage(imageutils.NodePerfNpbEp), imageutils.GetE2EImage(imageutils.NodePerfNpbIs), imageutils.GetE2EImage(imageutils.NodePerfTfWideDeep), @@ -75,7 +74,16 @@ func updateImageAllowList() { framework.ImagePrePullList = NodePrePullImageList.Union(commontest.PrePulledImages) // Images from extra envs framework.ImagePrePullList.Insert(getNodeProblemDetectorImage()) - framework.ImagePrePullList.Insert(getSRIOVDevicePluginImage()) + if sriovDevicePluginImage, err := getSRIOVDevicePluginImage(); err != nil { + klog.Errorln(err) + } else { + framework.ImagePrePullList.Insert(sriovDevicePluginImage) + } + if gpuDevicePluginImage, err := getGPUDevicePluginImage(); err != nil { + klog.Errorln(err) + } else { + framework.ImagePrePullList.Insert(gpuDevicePluginImage) + } } func getNodeProblemDetectorImage() string { @@ -214,42 +222,35 @@ func PrePullAllImages() error { } // getGPUDevicePluginImage returns the image of GPU device plugin. -func getGPUDevicePluginImage() string { +func getGPUDevicePluginImage() (string, error) { ds, err := e2emanifest.DaemonSetFromURL(e2egpu.GPUDevicePluginDSYAML) if err != nil { - klog.Errorf("Failed to parse the device plugin image: %v", err) - return "" + return "", fmt.Errorf("failed to parse the device plugin image: %w", err) } if ds == nil { - klog.Errorf("Failed to parse the device plugin image: the extracted DaemonSet is nil") - return "" + return "", fmt.Errorf("failed to parse the device plugin image: the extracted DaemonSet is nil") } if len(ds.Spec.Template.Spec.Containers) < 1 { - klog.Errorf("Failed to parse the device plugin image: cannot extract the container from YAML") - return "" + return "", fmt.Errorf("failed to parse the device plugin image: cannot extract the container from YAML") } - return ds.Spec.Template.Spec.Containers[0].Image + return ds.Spec.Template.Spec.Containers[0].Image, nil } // getSRIOVDevicePluginImage returns the image of SRIOV device plugin. -func getSRIOVDevicePluginImage() string { +func getSRIOVDevicePluginImage() (string, error) { data, err := e2etestfiles.Read(SRIOVDevicePluginDSYAML) if err != nil { - klog.Errorf("Failed to read the device plugin manifest: %v", err) - return "" + return "", fmt.Errorf("failed to read the device plugin manifest: %w", err) } ds, err := e2emanifest.DaemonSetFromData(data) if err != nil { - klog.Errorf("Failed to parse the device plugin image: %v", err) - return "" + return "", fmt.Errorf("failed to parse the device plugin image: %w", err) } if ds == nil { - klog.Errorf("Failed to parse the device plugin image: the extracted DaemonSet is nil") - return "" + return "", fmt.Errorf("failed to parse the device plugin image: the extracted DaemonSet is nil") } if len(ds.Spec.Template.Spec.Containers) < 1 { - klog.Errorf("Failed to parse the device plugin image: cannot extract the container from YAML") - return "" + return "", fmt.Errorf("failed to parse the device plugin image: cannot extract the container from YAML") } - return ds.Spec.Template.Spec.Containers[0].Image + return ds.Spec.Template.Spec.Containers[0].Image, nil }