Skip to content

Commit f1b218a

Browse files
committed
Support the DevicePluginCDIDevices feature gate
This patch adds support for the `DevicePluginCDIDevices` feature gate by adding `spec.operator.useDevicePluginCDIDevicesFeature` to `ClusterPolicy`. When this field is set, the operator sets the `DEVICE_LIST_STRATEGY` device plug-in environment variable to `cdi-cri`. Signed-off-by: Jean-Francois Roy <jeroy@nvidia.com>
1 parent 4f8f3f7 commit f1b218a

8 files changed

Lines changed: 39 additions & 1 deletion

File tree

api/nvidia/v1/clusterpolicy_types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ type OperatorSpec struct {
145145
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="On OpenShift, enable DriverToolkit image to build and install driver modules"
146146
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch"
147147
UseOpenShiftDriverToolkit *bool `json:"use_ocp_driver_toolkit,omitempty"`
148+
149+
// UseDevicePluginCDIDevicesFeature indicates if the device plug-in should be configured to use the CDI devices feature
150+
UseDevicePluginCDIDevicesFeature *bool `json:"useDevicePluginCDIDevicesFeature,omitempty"`
148151
}
149152

150153
// HostPathsSpec defines various paths on the host needed by GPU Operator components
@@ -1855,6 +1858,15 @@ func ImagePullPolicy(pullPolicy string) corev1.PullPolicy {
18551858
return imagePullPolicy
18561859
}
18571860

1861+
// DevicePluginCDIDevicesFeatureEnabled returns true if use DevicePluginCDIDevices feature is enabled
1862+
func (s *OperatorSpec) DevicePluginCDIDevicesFeatureEnabled() bool {
1863+
if s.UseDevicePluginCDIDevicesFeature == nil {
1864+
// default is false if not specified by user
1865+
return false
1866+
}
1867+
return *s.UseDevicePluginCDIDevicesFeature
1868+
}
1869+
18581870
// IsEnabled returns true if driver install is enabled(default) through gpu-operator
18591871
func (d *DriverSpec) IsEnabled() bool {
18601872
if d.Enabled == nil {

api/nvidia/v1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/manifests/nvidia.com_clusterpolicies.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,10 @@ spec:
15831583
image should be used on OpenShift to build and install driver
15841584
modules
15851585
type: boolean
1586+
useDevicePluginCDIDevicesFeature:
1587+
description: UseDevicePluginCDIDevicesFeature indicates if the device plug-in
1588+
should be configured to use the CDI devices feature
1589+
type: boolean
15861590
required:
15871591
- defaultRuntime
15881592
type: object

config/crd/bases/nvidia.com_clusterpolicies.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,10 @@ spec:
15831583
image should be used on OpenShift to build and install driver
15841584
modules
15851585
type: boolean
1586+
useDevicePluginCDIDevicesFeature:
1587+
description: UseDevicePluginCDIDevicesFeature indicates if the
1588+
device plug-in should be configured to use the CDI devices feature
1589+
type: boolean
15861590
required:
15871591
- defaultRuntime
15881592
type: object

controllers/object_controls.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1441,7 +1441,11 @@ func TransformDevicePlugin(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpe
14411441
// update env required for CDI support
14421442
if config.CDI.IsEnabled() {
14431443
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), CDIEnabledEnvName, "true")
1444-
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), DeviceListStrategyEnvName, "envvar,cdi-annotations")
1444+
if config.Operator.DevicePluginCDIDevicesFeatureEnabled() {
1445+
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), DeviceListStrategyEnvName, "cdi-cri")
1446+
} else {
1447+
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), DeviceListStrategyEnvName, "envvar,cdi-annotations")
1448+
}
14451449
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), CDIAnnotationPrefixEnvName, "nvidia.cdi.k8s.io/")
14461450
if config.Toolkit.IsEnabled() {
14471451
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), NvidiaCDIHookPathEnvName, filepath.Join(config.Toolkit.InstallDir, "toolkit/nvidia-cdi-hook"))

deployments/gpu-operator/crds/nvidia.com_clusterpolicies.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,10 @@ spec:
15831583
image should be used on OpenShift to build and install driver
15841584
modules
15851585
type: boolean
1586+
useDevicePluginCDIDevicesFeature:
1587+
description: UseDevicePluginCDIDevicesFeature indicates if the device plug-in
1588+
should be configured to use the CDI devices feature
1589+
type: boolean
15861590
required:
15871591
- defaultRuntime
15881592
type: object

deployments/gpu-operator/templates/clusterpolicy.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ spec:
4343
{{- if .Values.operator.use_ocp_driver_toolkit }}
4444
use_ocp_driver_toolkit: {{ .Values.operator.use_ocp_driver_toolkit }}
4545
{{- end }}
46+
{{- if .Values.operator.useDevicePluginCDIDevicesFeature }}
47+
useDevicePluginCDIDevicesFeature: {{ .Values.operator.useDevicePluginCDIDevicesFeature }}
48+
{{- end }}
4649
daemonsets:
4750
labels:
4851
{{- include "gpu-operator.operand-labels" . | nindent 6 }}

deployments/gpu-operator/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ operator:
7979
# upgrade CRD on chart upgrade, requires --disable-openapi-validation flag
8080
# to be passed during helm upgrade.
8181
upgradeCRD: true
82+
# use DevicePluginCDIDevices feature
83+
useDevicePluginCDIDevicesFeature: false
8284
initContainer:
8385
image: cuda
8486
repository: nvcr.io/nvidia

0 commit comments

Comments
 (0)