mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Remove COS requirement while running e2e nvidia gpu tests.
This commit is contained in:
parent
1f4f0123ed
commit
af3bc705b5
@ -18,7 +18,6 @@ package scheduling
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
@ -35,7 +34,6 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
testPodNamePrefix = "nvidia-gpu-"
|
testPodNamePrefix = "nvidia-gpu-"
|
||||||
cosOSImage = "Container-Optimized OS from Google"
|
|
||||||
// Nvidia driver installation can take upwards of 5 minutes.
|
// Nvidia driver installation can take upwards of 5 minutes.
|
||||||
driverInstallTimeout = 10 * time.Minute
|
driverInstallTimeout = 10 * time.Minute
|
||||||
)
|
)
|
||||||
@ -69,16 +67,13 @@ func makeCudaAdditionDevicePluginTestPod() *v1.Pod {
|
|||||||
return testPod
|
return testPod
|
||||||
}
|
}
|
||||||
|
|
||||||
func isClusterRunningCOS(f *framework.Framework) bool {
|
func logOSImages(f *framework.Framework) {
|
||||||
nodeList, err := f.ClientSet.CoreV1().Nodes().List(metav1.ListOptions{})
|
nodeList, err := f.ClientSet.CoreV1().Nodes().List(metav1.ListOptions{})
|
||||||
framework.ExpectNoError(err, "getting node list")
|
framework.ExpectNoError(err, "getting node list")
|
||||||
for _, node := range nodeList.Items {
|
for _, node := range nodeList.Items {
|
||||||
if !strings.Contains(node.Status.NodeInfo.OSImage, cosOSImage) {
|
framework.Logf("OS Image: %v", node.Status.NodeInfo.OSImage)
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func areGPUsAvailableOnAllSchedulableNodes(f *framework.Framework) bool {
|
func areGPUsAvailableOnAllSchedulableNodes(f *framework.Framework) bool {
|
||||||
framework.Logf("Getting list of Nodes from API server")
|
framework.Logf("Getting list of Nodes from API server")
|
||||||
@ -111,14 +106,7 @@ func getGPUsAvailable(f *framework.Framework) int64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SetupNVIDIAGPUNode(f *framework.Framework, setupResourceGatherer bool) *framework.ContainerResourceGatherer {
|
func SetupNVIDIAGPUNode(f *framework.Framework, setupResourceGatherer bool) *framework.ContainerResourceGatherer {
|
||||||
// Skip the test if the base image is not COS.
|
logOSImages(f)
|
||||||
// TODO: Add support for other base images.
|
|
||||||
// CUDA apps require host mounts which is not portable across base images (yet).
|
|
||||||
framework.Logf("Checking base image")
|
|
||||||
if !isClusterRunningCOS(f) {
|
|
||||||
Skip("Nvidia GPU tests are supproted only on Container Optimized OS image currently")
|
|
||||||
}
|
|
||||||
framework.Logf("Cluster is running on COS. Proceeding with test")
|
|
||||||
|
|
||||||
dsYamlUrlFromEnv := os.Getenv("NVIDIA_DRIVER_INSTALLER_DAEMONSET")
|
dsYamlUrlFromEnv := os.Getenv("NVIDIA_DRIVER_INSTALLER_DAEMONSET")
|
||||||
if dsYamlUrlFromEnv != "" {
|
if dsYamlUrlFromEnv != "" {
|
||||||
@ -163,7 +151,7 @@ func SetupNVIDIAGPUNode(f *framework.Framework, setupResourceGatherer bool) *fra
|
|||||||
return rsgather
|
return rsgather
|
||||||
}
|
}
|
||||||
|
|
||||||
func testNvidiaGPUsOnCOS(f *framework.Framework) {
|
func testNvidiaGPUs(f *framework.Framework) {
|
||||||
rsgather := SetupNVIDIAGPUNode(f, true)
|
rsgather := SetupNVIDIAGPUNode(f, true)
|
||||||
framework.Logf("Creating as many pods as there are Nvidia GPUs and have the pods run a CUDA app")
|
framework.Logf("Creating as many pods as there are Nvidia GPUs and have the pods run a CUDA app")
|
||||||
podList := []*v1.Pod{}
|
podList := []*v1.Pod{}
|
||||||
@ -186,7 +174,7 @@ func testNvidiaGPUsOnCOS(f *framework.Framework) {
|
|||||||
|
|
||||||
var _ = SIGDescribe("[Feature:GPUDevicePlugin]", func() {
|
var _ = SIGDescribe("[Feature:GPUDevicePlugin]", func() {
|
||||||
f := framework.NewDefaultFramework("device-plugin-gpus")
|
f := framework.NewDefaultFramework("device-plugin-gpus")
|
||||||
It("run Nvidia GPU Device Plugin tests on Container Optimized OS only", func() {
|
It("run Nvidia GPU Device Plugin tests", func() {
|
||||||
testNvidiaGPUsOnCOS(f)
|
testNvidiaGPUs(f)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user