should log error when error in parsing device plugin image

This commit is contained in:
tianshapjq
2018-02-02 08:51:09 +08:00
parent 551f73d324
commit d17f1ce5bf
2 changed files with 18 additions and 5 deletions

View File

@@ -21,6 +21,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/uuid"
"fmt"
. "github.com/onsi/gomega"
)
@@ -67,10 +68,16 @@ func NVIDIADevicePlugin(ns string) *v1.Pod {
return p
}
func GetGPUDevicePluginImage() string {
func GetGPUDevicePluginImage() (string, error) {
ds, err := DsFromManifest(GPUDevicePluginDSYAML)
if err != nil || ds == nil || len(ds.Spec.Template.Spec.Containers) < 1 {
return ""
if err != nil {
return "", err
}
return ds.Spec.Template.Spec.Containers[0].Image
if ds == nil {
return "", fmt.Errorf("empty DaemonSet from DSYAML")
}
if len(ds.Spec.Template.Spec.Containers) < 1 {
return "", fmt.Errorf("no container specified in the DSYAML")
}
return ds.Spec.Template.Spec.Containers[0].Image, nil
}

View File

@@ -52,12 +52,18 @@ var NodeImageWhiteList = sets.NewString(
imageutils.GetE2EImage(imageutils.Netexec),
imageutils.GetE2EImage(imageutils.Nonewprivs),
imageutils.GetPauseImageNameForHostArch(),
framework.GetGPUDevicePluginImage(),
)
func init() {
// Union NodeImageWhiteList and CommonImageWhiteList into the framework image white list.
framework.ImageWhiteList = NodeImageWhiteList.Union(commontest.CommonImageWhiteList)
// parse the device plugin image from url
if image, err := framework.GetGPUDevicePluginImage(); err != nil {
glog.Errorf("Failed to parse the device plugin image: %v", err)
} else {
framework.ImageWhiteList.Insert(image)
}
}
// puller represents a generic image puller