(c *cli.Context, o *options)
| 325 | } |
| 326 | |
| 327 | func startPlugins(c *cli.Context, o *options) ([]plugin.Interface, bool, error) { |
| 328 | // Load the configuration file |
| 329 | klog.Info("Loading configuration.") |
| 330 | config, err := loadConfig(c, o.flags) |
| 331 | if err != nil { |
| 332 | return nil, false, fmt.Errorf("unable to load config: %v", err) |
| 333 | } |
| 334 | spec.DisableResourceNamingInConfig(config) |
| 335 | |
| 336 | driverRoot := root(*config.Flags.Plugin.ContainerDriverRoot) |
| 337 | // We construct an NVML library specifying the path to libnvidia-ml.so.1 |
| 338 | // explicitly so that we don't have to rely on the library path. |
| 339 | nvmllib := nvml.New( |
| 340 | nvml.WithLibraryPath(driverRoot.tryResolveLibrary("libnvidia-ml.so.1")), |
| 341 | ) |
| 342 | devicelib := device.New(nvmllib) |
| 343 | infolib := nvinfo.New( |
| 344 | nvinfo.WithRoot(string(driverRoot)), |
| 345 | nvinfo.WithNvmlLib(nvmllib), |
| 346 | nvinfo.WithDeviceLib(devicelib), |
| 347 | ) |
| 348 | |
| 349 | err = validateFlags(infolib, config) |
| 350 | if err != nil { |
| 351 | return nil, false, fmt.Errorf("unable to validate flags: %v", err) |
| 352 | } |
| 353 | |
| 354 | // Update the configuration file with default resources. |
| 355 | klog.Info("Updating config with default resource matching patterns.") |
| 356 | err = rm.AddDefaultResourcesToConfig(infolib, nvmllib, devicelib, config) |
| 357 | if err != nil { |
| 358 | return nil, false, fmt.Errorf("unable to add default resources to config: %v", err) |
| 359 | } |
| 360 | |
| 361 | // Print the config to the output. |
| 362 | configJSON, err := json.MarshalIndent(config, "", " ") |
| 363 | if err != nil { |
| 364 | return nil, false, fmt.Errorf("failed to marshal config to JSON: %v", err) |
| 365 | } |
| 366 | klog.Infof("\nRunning with config:\n%v", string(configJSON)) |
| 367 | |
| 368 | // Get the set of plugins. |
| 369 | klog.Info("Retrieving plugins.") |
| 370 | plugins, err := GetPlugins(c.Context, infolib, nvmllib, devicelib, config, o) |
| 371 | if err != nil { |
| 372 | return nil, false, fmt.Errorf("error getting plugins: %v", err) |
| 373 | } |
| 374 | |
| 375 | // Loop through all plugins, starting them if they have any devices |
| 376 | // to serve. If even one plugin fails to start properly, try |
| 377 | // starting them all again. |
| 378 | started := 0 |
| 379 | for _, p := range plugins { |
| 380 | // Just continue if there are no devices to serve for plugin p. |
| 381 | if len(p.Devices()) == 0 { |
| 382 | continue |
| 383 | } |
| 384 |
no test coverage detected