Skip to content

Commit c829806

Browse files
committed
Allow CDI feature flags to be set
This change allows specific nvcdi feature flags to be set. These are relevant when the device plugin is configured with a device strategy of cdi-cri or cdi-annotations. Signed-off-by: Evan Lezar <[email protected]>
1 parent 108ea3b commit c829806

File tree

5 files changed

+24
-0
lines changed

5 files changed

+24
-0
lines changed

cmd/nvidia-device-plugin/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ func main() {
169169
Usage: "The specified IMEX channels are required",
170170
EnvVars: []string{"IMEX_REQUIRED"},
171171
},
172+
&cli.StringSliceFlag{
173+
Name: "cdi-feature-flags",
174+
Usage: "A set of feature flags to be passed to the CDI spec generation logic",
175+
EnvVars: []string{"CDI_FEATURE_FLAGS"},
176+
},
172177
}
173178
o.flags = c.Flags
174179

deployments/helm/nvidia-device-plugin/templates/daemonset-device-plugin.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ spec:
169169
- name: NVIDIA_CDI_HOOK_PATH
170170
value: {{ .Values.cdi.nvidiaHookPath }}
171171
{{- end }}
172+
{{- if typeIs "string" .Values.cdi.featureFlags }}
173+
- name: CDI_FEATURE_FLAGS
174+
value: {{ .Values.cdi.featureFlags }}
175+
{{- end }}
172176
{{- if typeIs "bool" .Values.gdrcopyEnabled }}
173177
- name: GDRCOPY_ENABLED
174178
value: {{ .Values.gdrcopyEnabled | quote }}

deployments/helm/nvidia-device-plugin/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,6 @@ cdi:
163163
# nvidiaHookPath specifies the path to the nvidia-cdi-hook or nvidia-ctk executables on the host.
164164
# This is required to ensure that the generated CDI specification refers to the correct CDI hooks.
165165
nvidiaHookPath: null
166+
# featureFlags allows CDI feature flags to be specified for CDI specification generation.
167+
# This is specified as a comma-separated list of strings.
168+
featureFlags: null

internal/cdi/cdi.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ type cdiHandler struct {
5757

5858
deviceListStrategies spec.DeviceListStrategies
5959

60+
// nvcdiFeatureFlags allows finer control over CDI spec generation.
61+
nvcdiFeatureFlags []string
62+
6063
gdsEnabled bool
6164
mofedEnabled bool
6265
gdrcopyEnabled bool
@@ -117,6 +120,7 @@ func New(infolib info.Interface, nvmllib nvml.Interface, devicelib device.Interf
117120
nvcdi.WithDeviceLib(c.devicelib),
118121
nvcdi.WithDevRoot(c.devRoot),
119122
nvcdi.WithDriverRoot(c.driverRoot),
123+
nvcdi.WithFeatureFlags(c.nvcdiFeatureFlags...),
120124
nvcdi.WithInfoLib(c.infolib),
121125
nvcdi.WithLogger(c.logger),
122126
nvcdi.WithNVIDIACDIHookPath(c.nvidiaCTKPath),

internal/cdi/options.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ import (
2424
// Option defines a function for passing options to the New() call
2525
type Option func(*cdiHandler)
2626

27+
// WithFeatureFlags provides and option to set the feature flags for the nvcdi
28+
// spec generation instance.
29+
func WithFeatureFlags(featureFlags ...string) Option {
30+
return func(c *cdiHandler) {
31+
c.nvcdiFeatureFlags = featureFlags
32+
}
33+
}
34+
2735
// WithDeviceListStrategies provides an Option to set the enabled flag used by the 'cdi' interface
2836
func WithDeviceListStrategies(deviceListStrategies spec.DeviceListStrategies) Option {
2937
return func(c *cdiHandler) {

0 commit comments

Comments
 (0)