MCPcopy
hub / github.com/NVIDIA/k8s-device-plugin / devicePluginForResource

Method devicePluginForResource

internal/plugin/server.go:73–100  ·  view source on GitHub ↗

devicePluginForResource creates a device plugin for the specified resource.

(ctx context.Context, resourceManager rm.ResourceManager)

Source from the content-addressed store, hash-verified

71
72// devicePluginForResource creates a device plugin for the specified resource.
73func (o *options) devicePluginForResource(ctx context.Context, resourceManager rm.ResourceManager) (Interface, error) {
74 mpsOptions, err := o.getMPSOptions(resourceManager)
75 if err != nil {
76 return nil, err
77 }
78
79 plugin := nvidiaDevicePlugin{
80 ctx: ctx,
81 rm: resourceManager,
82 config: o.config,
83 deviceListStrategies: o.deviceListStrategies,
84
85 cdiHandler: o.cdiHandler,
86 cdiAnnotationPrefix: *o.config.Flags.Plugin.CDIAnnotationPrefix,
87
88 imexChannels: o.imexChannels,
89
90 mps: mpsOptions,
91
92 socket: getPluginSocketPath(resourceManager.Resource()),
93 // These will be reinitialized every
94 // time the plugin server is restarted.
95 server: nil,
96 health: nil,
97 stop: nil,
98 }
99 return &plugin, nil
100}
101
102// getPluginSocketPath returns the socket to use for the specified resource.
103func getPluginSocketPath(resource spec.ResourceName) string {

Callers 1

NewFunction · 0.95

Calls 3

getMPSOptionsMethod · 0.95
getPluginSocketPathFunction · 0.85
ResourceMethod · 0.65

Tested by

no test coverage detected