Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 23 additions & 20 deletions cmd/nvidia-device-plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ import (
)

type options struct {
flags []cli.Flag
configFile string
kubeletSocket string
flags []cli.Flag
configFile string
kubeletSocket string
cdiFeatureFlags cli.StringSlice
}

func main() {
Expand Down Expand Up @@ -115,19 +116,6 @@ func main() {
Usage: "ensure that containers that request NVIDIA GPU resources are started with MOFED support",
EnvVars: []string{"MOFED_ENABLED"},
},
&cli.StringFlag{
Name: "kubelet-socket",
Value: pluginapi.KubeletSocket,
Usage: "specify the socket for communicating with the kubelet; if this is empty, no connection with the kubelet is attempted",
Destination: &o.kubeletSocket,
EnvVars: []string{"KUBELET_SOCKET"},
},
&cli.StringFlag{
Name: "config-file",
Usage: "the path to a config file as an alternative to command line options or environment variables",
Destination: &o.configFile,
EnvVars: []string{"CONFIG_FILE"},
},
&cli.StringFlag{
Name: "cdi-annotation-prefix",
Value: spec.DefaultCDIAnnotationPrefix,
Expand Down Expand Up @@ -169,10 +157,25 @@ func main() {
Usage: "The specified IMEX channels are required",
EnvVars: []string{"IMEX_REQUIRED"},
},
// The following CLI flags do not have equivalents in the config file.
&cli.StringFlag{
Name: "kubelet-socket",
Value: pluginapi.KubeletSocket,
Usage: "specify the socket for communicating with the kubelet; if this is empty, no connection with the kubelet is attempted",
Destination: &o.kubeletSocket,
EnvVars: []string{"KUBELET_SOCKET"},
},
&cli.StringFlag{
Name: "config-file",
Usage: "the path to a config file as an alternative to command line options or environment variables",
Destination: &o.configFile,
EnvVars: []string{"CONFIG_FILE"},
},
&cli.StringSliceFlag{
Name: "cdi-feature-flags",
Usage: "A set of feature flags to be passed to the CDI spec generation logic",
EnvVars: []string{"CDI_FEATURE_FLAGS"},
Name: "cdi-feature-flags",
Usage: "A set of feature flags to be passed to the CDI spec generation logic",
EnvVars: []string{"CDI_FEATURE_FLAGS"},
Destination: &o.cdiFeatureFlags,
},
}
o.flags = c.Flags
Expand Down Expand Up @@ -364,7 +367,7 @@ func startPlugins(c *cli.Context, o *options) ([]plugin.Interface, bool, error)

// Get the set of plugins.
klog.Info("Retrieving plugins.")
plugins, err := GetPlugins(c.Context, infolib, nvmllib, devicelib, config)
plugins, err := GetPlugins(c.Context, infolib, nvmllib, devicelib, config, o)
if err != nil {
return nil, false, fmt.Errorf("error getting plugins: %v", err)
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/nvidia-device-plugin/plugin-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
)

// GetPlugins returns a set of plugins for the specified configuration.
func GetPlugins(ctx context.Context, infolib info.Interface, nvmllib nvml.Interface, devicelib device.Interface, config *spec.Config) ([]plugin.Interface, error) {
func GetPlugins(ctx context.Context, infolib info.Interface, nvmllib nvml.Interface, devicelib device.Interface, config *spec.Config, o *options) ([]plugin.Interface, error) {
// TODO: We could consider passing this as an argument since it should already be used to construct nvmllib.
driverRoot := root(*config.Flags.Plugin.ContainerDriverRoot)

Expand All @@ -58,6 +58,7 @@ func GetPlugins(ctx context.Context, infolib info.Interface, nvmllib nvml.Interf
cdi.WithGdsEnabled(*config.Flags.GDSEnabled),
cdi.WithMofedEnabled(*config.Flags.MOFEDEnabled),
cdi.WithImexChannels(imexChannels),
cdi.WithFeatureFlags(o.cdiFeatureFlags.Value()...),
)
if err != nil {
return nil, fmt.Errorf("unable to create cdi handler: %v", err)
Expand Down
Loading