mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 18:53:35 +00:00
vendor updates
This commit is contained in:
42
vendor/k8s.io/kubernetes/test/e2e/scheduling/nvidia-gpus.go
generated
vendored
42
vendor/k8s.io/kubernetes/test/e2e/scheduling/nvidia-gpus.go
generated
vendored
@ -17,6 +17,7 @@ limitations under the License.
|
||||
package scheduling
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -152,7 +153,7 @@ func getGPUsAvailable(f *framework.Framework) int64 {
|
||||
return gpusAvailable
|
||||
}
|
||||
|
||||
func testNvidiaGPUsOnCOS(f *framework.Framework) {
|
||||
func SetupNVIDIAGPUNode(f *framework.Framework, setupResourceGatherer bool) *framework.ContainerResourceGatherer {
|
||||
// Skip the test if the base image is not COS.
|
||||
// TODO: Add support for other base images.
|
||||
// CUDA apps require host mounts which is not portable across base images (yet).
|
||||
@ -162,36 +163,46 @@ func testNvidiaGPUsOnCOS(f *framework.Framework) {
|
||||
}
|
||||
framework.Logf("Cluster is running on COS. Proceeding with test")
|
||||
|
||||
if f.BaseName == "device-plugin-gpus" {
|
||||
dsYamlUrl = "https://raw.githubusercontent.com/GoogleCloudPlatform/container-engine-accelerators/k8s-1.9/daemonset.yaml"
|
||||
gpuResourceName = framework.NVIDIAGPUResourceName
|
||||
podCreationFunc = makeCudaAdditionDevicePluginTestPod
|
||||
} else {
|
||||
if f.BaseName == "gpus" {
|
||||
dsYamlUrl = "https://raw.githubusercontent.com/ContainerEngine/accelerators/master/cos-nvidia-gpu-installer/daemonset.yaml"
|
||||
gpuResourceName = v1.ResourceNvidiaGPU
|
||||
podCreationFunc = makeCudaAdditionTestPod
|
||||
} else {
|
||||
dsYamlUrlFromEnv := os.Getenv("NVIDIA_DRIVER_INSTALLER_DAEMONSET")
|
||||
if dsYamlUrlFromEnv != "" {
|
||||
dsYamlUrl = dsYamlUrlFromEnv
|
||||
} else {
|
||||
dsYamlUrl = "https://raw.githubusercontent.com/GoogleCloudPlatform/container-engine-accelerators/master/daemonset.yaml"
|
||||
}
|
||||
gpuResourceName = framework.NVIDIAGPUResourceName
|
||||
podCreationFunc = makeCudaAdditionDevicePluginTestPod
|
||||
}
|
||||
|
||||
framework.Logf("Using %v", dsYamlUrl)
|
||||
// Creates the DaemonSet that installs Nvidia Drivers.
|
||||
// The DaemonSet also runs nvidia device plugin for device plugin test.
|
||||
ds, err := framework.DsFromManifest(dsYamlUrl)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
ds.Namespace = f.Namespace.Name
|
||||
_, err = f.ClientSet.ExtensionsV1beta1().DaemonSets(f.Namespace.Name).Create(ds)
|
||||
framework.ExpectNoError(err, "failed to create daemonset")
|
||||
framework.ExpectNoError(err, "failed to create nvidia-driver-installer daemonset")
|
||||
framework.Logf("Successfully created daemonset to install Nvidia drivers.")
|
||||
|
||||
pods, err := framework.WaitForControlledPods(f.ClientSet, ds.Namespace, ds.Name, extensionsinternal.Kind("DaemonSet"))
|
||||
framework.ExpectNoError(err, "getting pods controlled by the daemonset")
|
||||
framework.ExpectNoError(err, "failed to get pods controlled by the nvidia-driver-installer daemonset")
|
||||
|
||||
devicepluginPods, err := framework.WaitForControlledPods(f.ClientSet, "kube-system", "nvidia-gpu-device-plugin", extensionsinternal.Kind("DaemonSet"))
|
||||
if err == nil {
|
||||
framework.Logf("Adding deviceplugin addon pod.")
|
||||
pods.Items = append(pods.Items, devicepluginPods.Items...)
|
||||
}
|
||||
framework.Logf("Starting ResourceUsageGather for the created DaemonSet pods.")
|
||||
rsgather, err := framework.NewResourceUsageGatherer(f.ClientSet, framework.ResourceGathererOptions{false, false, 2 * time.Second, 2 * time.Second, true}, pods)
|
||||
framework.ExpectNoError(err, "creating ResourceUsageGather for the daemonset pods")
|
||||
go rsgather.StartGatheringData()
|
||||
|
||||
var rsgather *framework.ContainerResourceGatherer
|
||||
if setupResourceGatherer {
|
||||
framework.Logf("Starting ResourceUsageGather for the created DaemonSet pods.")
|
||||
rsgather, err = framework.NewResourceUsageGatherer(f.ClientSet, framework.ResourceGathererOptions{false, false, 2 * time.Second, 2 * time.Second, true}, pods)
|
||||
framework.ExpectNoError(err, "creating ResourceUsageGather for the daemonset pods")
|
||||
go rsgather.StartGatheringData()
|
||||
}
|
||||
|
||||
// Wait for Nvidia GPUs to be available on nodes
|
||||
framework.Logf("Waiting for drivers to be installed and GPUs to be available in Node Capacity...")
|
||||
@ -199,6 +210,11 @@ func testNvidiaGPUsOnCOS(f *framework.Framework) {
|
||||
return areGPUsAvailableOnAllSchedulableNodes(f)
|
||||
}, driverInstallTimeout, time.Second).Should(BeTrue())
|
||||
|
||||
return rsgather
|
||||
}
|
||||
|
||||
func testNvidiaGPUsOnCOS(f *framework.Framework) {
|
||||
rsgather := SetupNVIDIAGPUNode(f, true)
|
||||
framework.Logf("Creating as many pods as there are Nvidia GPUs and have the pods run a CUDA app")
|
||||
podList := []*v1.Pod{}
|
||||
for i := int64(0); i < getGPUsAvailable(f); i++ {
|
||||
|
Reference in New Issue
Block a user