Skip to content

Commit 041d4d4

Browse files
authored
Merge pull request #1818 from cdesiniotis/cdi-disable-hooks
Allow CDI hooks to be disabled
2 parents df9ddaf + 32bf013 commit 041d4d4

4 files changed

Lines changed: 20 additions & 0 deletions

File tree

cmd/nvidia-device-plugin/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ type options struct {
4545
configFile string
4646
kubeletSocket string
4747
cdiFeatureFlags cli.StringSlice
48+
cdiDisableHooks cli.StringSlice
4849
}
4950

5051
func main() {
@@ -180,6 +181,12 @@ func main() {
180181
EnvVars: []string{"CDI_FEATURE_FLAGS"},
181182
Destination: &o.cdiFeatureFlags,
182183
},
184+
&cli.StringSliceFlag{
185+
Name: "cdi-disable-hooks",
186+
Usage: "A set of OCI hooks to disable when generating CDI specifications; if the value 'all' is specified, then the CDI specification will exclude all OCI hooks.",
187+
EnvVars: []string{"CDI_DISABLE_HOOKS"},
188+
Destination: &o.cdiDisableHooks,
189+
},
183190
}
184191
o.flags = c.Flags
185192

cmd/nvidia-device-plugin/plugin-manager.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func GetPlugins(ctx context.Context, infolib info.Interface, nvmllib nvml.Interf
6363
cdi.WithMofedEnabled(*config.Flags.MOFEDEnabled),
6464
cdi.WithImexChannels(imexChannels),
6565
cdi.WithFeatureFlags(o.cdiFeatureFlags.Value()...),
66+
cdi.WithDisabledHooks(o.cdiDisableHooks.Value()...),
6667
cdi.WithDeviceDiscoveryStrategy(resolvedStrategy),
6768
)
6869
if err != nil {

internal/cdi/cdi.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ type cdiHandler struct {
6262
// nvcdiFeatureFlags allows finer control over CDI spec generation.
6363
nvcdiFeatureFlags []string
6464

65+
// nvcdiDisabledHooks is a list of hooks to omit when generating CDI specs
66+
nvcdiDisabledHooks []string
67+
6568
gdsEnabled bool
6669
mofedEnabled bool
6770
gdrcopyEnabled bool
@@ -126,6 +129,7 @@ func New(infolib info.Interface, nvmllib nvml.Interface, devicelib device.Interf
126129
nvcdi.WithDevRoot(c.devRoot),
127130
nvcdi.WithDriverRoot(c.driverRoot),
128131
nvcdi.WithFeatureFlags(c.nvcdiFeatureFlags...),
132+
nvcdi.WithDisabledHooks(c.nvcdiDisabledHooks...),
129133
nvcdi.WithInfoLib(c.infolib),
130134
nvcdi.WithLogger(c.logger),
131135
nvcdi.WithNVIDIACDIHookPath(c.nvidiaCTKPath),

internal/cdi/options.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ func WithFeatureFlags(featureFlags ...string) Option {
3232
}
3333
}
3434

35+
// WithDisabledHooks provides and option to disable hooks for the nvcdi
36+
// spec generation instance.
37+
func WithDisabledHooks(disabledHooks ...string) Option {
38+
return func(c *cdiHandler) {
39+
c.nvcdiDisabledHooks = disabledHooks
40+
}
41+
}
42+
3543
// WithDeviceListStrategies provides an Option to set the enabled flag used by the 'cdi' interface
3644
func WithDeviceListStrategies(deviceListStrategies spec.DeviceListStrategies) Option {
3745
return func(c *cdiHandler) {

0 commit comments

Comments
 (0)