From d17f1ce5bfa3a6b7888a03ed0471ed87d24d9566 Mon Sep 17 00:00:00 2001 From: tianshapjq Date: Fri, 2 Feb 2018 08:51:09 +0800 Subject: [PATCH 1/3] should log error when error in parsing device plugin image --- test/e2e/framework/gpu_util.go | 15 +++++++++++---- test/e2e_node/image_list.go | 8 +++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/test/e2e/framework/gpu_util.go b/test/e2e/framework/gpu_util.go index 2cd9f33ee77..54aa0c50d7f 100644 --- a/test/e2e/framework/gpu_util.go +++ b/test/e2e/framework/gpu_util.go @@ -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 } diff --git a/test/e2e_node/image_list.go b/test/e2e_node/image_list.go index b857700c14c..2143af779a7 100644 --- a/test/e2e_node/image_list.go +++ b/test/e2e_node/image_list.go @@ -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 From 15c6df5d01562f558308a53b481042f1ea901dfa Mon Sep 17 00:00:00 2001 From: tianshapjq Date: Wed, 7 Feb 2018 09:32:42 +0800 Subject: [PATCH 2/3] update --- test/e2e/framework/gpu_util.go | 15 +++++++++------ test/e2e_node/image_list.go | 8 +------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/test/e2e/framework/gpu_util.go b/test/e2e/framework/gpu_util.go index 54aa0c50d7f..abf2ed18da3 100644 --- a/test/e2e/framework/gpu_util.go +++ b/test/e2e/framework/gpu_util.go @@ -21,8 +21,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/uuid" - "fmt" . "github.com/onsi/gomega" + "github.com/golang/glog" ) const ( @@ -68,16 +68,19 @@ func NVIDIADevicePlugin(ns string) *v1.Pod { return p } -func GetGPUDevicePluginImage() (string, error) { +func GetGPUDevicePluginImage() string { ds, err := DsFromManifest(GPUDevicePluginDSYAML) if err != nil { - return "", err + glog.Errorf("Failed to parse the device plugin image: %v", err) + return "" } if ds == nil { - return "", fmt.Errorf("empty DaemonSet from DSYAML") + glog.Errorf("Failed to parse the device plugin image: the extracted DaemonSet is nil") + return "" } if len(ds.Spec.Template.Spec.Containers) < 1 { - return "", fmt.Errorf("no container specified in the DSYAML") + glog.Errorf("Failed to parse the device plugin image: cannot extract the container from YAML") + return "" } - return ds.Spec.Template.Spec.Containers[0].Image, nil + return ds.Spec.Template.Spec.Containers[0].Image } diff --git a/test/e2e_node/image_list.go b/test/e2e_node/image_list.go index 2143af779a7..b857700c14c 100644 --- a/test/e2e_node/image_list.go +++ b/test/e2e_node/image_list.go @@ -52,18 +52,12 @@ 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 From 26949f978a2811522985ce2b7c5d3746a5d7cf4c Mon Sep 17 00:00:00 2001 From: tianshapjq Date: Wed, 7 Feb 2018 10:18:32 +0800 Subject: [PATCH 3/3] update --- test/e2e/framework/gpu_util.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/framework/gpu_util.go b/test/e2e/framework/gpu_util.go index abf2ed18da3..0a48cc68fcc 100644 --- a/test/e2e/framework/gpu_util.go +++ b/test/e2e/framework/gpu_util.go @@ -21,8 +21,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/uuid" - . "github.com/onsi/gomega" "github.com/golang/glog" + . "github.com/onsi/gomega" ) const (