Skip to content

Commit fb869aa

Browse files
authored
Merge pull request #1749 from cdesiniotis/cnt-6359/set-gdrcopy-enabled-in-dp
Add GDRCOPY_ENABLED=true to device-plugin when GDRCopy is enabled
2 parents 891eca8 + 703a3ea commit fb869aa

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

controllers/object_controls.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ const (
133133
GDSEnabledEnvName = "GDS_ENABLED"
134134
// MOFEDEnabledEnvName is the env name to enable MOFED devices injection with device-plugin
135135
MOFEDEnabledEnvName = "MOFED_ENABLED"
136+
// GDRCopyEnabledEnvName is the envvar that enables injection of the GDRCopy device node with the device-plugin
137+
GDRCopyEnabledEnvName = "GDRCOPY_ENABLED"
136138
// ServiceMonitorCRDName is the name of the CRD defining the ServiceMonitor kind
137139
ServiceMonitorCRDName = "servicemonitors.monitoring.coreos.com"
138140
// DefaultToolkitInstallDir is the default toolkit installation directory on the host
@@ -1486,6 +1488,10 @@ func TransformDevicePlugin(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpe
14861488
setContainerEnv(mainContainer, MOFEDEnabledEnvName, "true")
14871489
}
14881490

1491+
if config.GDRCopy != nil && config.GDRCopy.IsEnabled() {
1492+
setContainerEnv(mainContainer, GDRCopyEnabledEnvName, "true")
1493+
}
1494+
14891495
// apply plugin configuration through ConfigMap if one is provided
14901496
err = handleDevicePluginConfig(obj, config)
14911497
if err != nil {

controllers/transforms_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,44 @@ func TestTransformDevicePlugin(t *testing.T) {
891891
},
892892
}).WithContainer(corev1.Container{Name: "dummy"}).WithPullSecret("pull-secret").WithRuntimeClassName("nvidia"),
893893
},
894+
{
895+
description: "transform device plugin, gds and gdrcopy enabled",
896+
ds: NewDaemonset().
897+
WithContainer(corev1.Container{Name: "nvidia-device-plugin"}),
898+
cpSpec: &gpuv1.ClusterPolicySpec{
899+
DevicePlugin: gpuv1.DevicePluginSpec{
900+
Repository: "nvcr.io/nvidia/cloud-native",
901+
Image: "nvidia-device-plugin",
902+
Version: "v1.0.0",
903+
ImagePullPolicy: "IfNotPresent",
904+
},
905+
Toolkit: gpuv1.ToolkitSpec{
906+
Enabled: newBoolPtr(true),
907+
InstallDir: "/path/to/install",
908+
},
909+
GDRCopy: &gpuv1.GDRCopySpec{
910+
Enabled: newBoolPtr(true),
911+
},
912+
GPUDirectStorage: &gpuv1.GPUDirectStorageSpec{
913+
Enabled: newBoolPtr(true),
914+
},
915+
},
916+
expectedDs: NewDaemonset().WithContainer(corev1.Container{
917+
Name: "nvidia-device-plugin",
918+
Image: "nvcr.io/nvidia/cloud-native/nvidia-device-plugin:v1.0.0",
919+
ImagePullPolicy: corev1.PullIfNotPresent,
920+
Env: []corev1.EnvVar{
921+
{Name: GDSEnabledEnvName, Value: "true"},
922+
{Name: MOFEDEnabledEnvName, Value: "true"},
923+
{Name: GDRCopyEnabledEnvName, Value: "true"},
924+
{Name: "NVIDIA_MIG_MONITOR_DEVICES", Value: "all"},
925+
{Name: CDIEnabledEnvName, Value: "true"},
926+
{Name: DeviceListStrategyEnvName, Value: "cdi-annotations,cdi-cri"},
927+
{Name: CDIAnnotationPrefixEnvName, Value: "cdi.k8s.io/"},
928+
{Name: NvidiaCDIHookPathEnvName, Value: "/path/to/install/toolkit/nvidia-cdi-hook"},
929+
},
930+
}).WithRuntimeClassName("nvidia"),
931+
},
894932
}
895933

896934
for _, tc := range testCases {

0 commit comments

Comments
 (0)