Skip to content

Commit

Permalink
log info when plugin is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmood Ali committed Jul 21, 2020
1 parent 6476390 commit 73fa874
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
6 changes: 5 additions & 1 deletion client/devicemanager/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,11 @@ START:

// Start fingerprinting
fingerprintCh, err := devicePlugin.Fingerprint(i.ctx)
if err != nil {
if err == device.ErrPluginDisabled {
i.logger.Info("fingerprinting failed: plugin is not enabled")
i.handleFingerprintError()
return
} else if err != nil {
i.logger.Error("fingerprinting failed", "error", err)
i.handleFingerprintError()
return
Expand Down
8 changes: 3 additions & 5 deletions devices/gpu/nvidia/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ var (
hclspec.NewLiteral("\"1m\""),
),
})

errDeviceNotEnabled = fmt.Errorf("Nvidia device is not enabled")
)

// Config contains configuration information for the plugin.
Expand Down Expand Up @@ -160,7 +158,7 @@ func (d *NvidiaDevice) SetConfig(cfg *base.Config) error {
// devices health changes, messages will be emitted.
func (d *NvidiaDevice) Fingerprint(ctx context.Context) (<-chan *device.FingerprintResponse, error) {
if !d.enabled {
return nil, errDeviceNotEnabled
return nil, device.ErrPluginDisabled
}

outCh := make(chan *device.FingerprintResponse)
Expand All @@ -184,7 +182,7 @@ func (d *NvidiaDevice) Reserve(deviceIDs []string) (*device.ContainerReservation
return &device.ContainerReservation{}, nil
}
if !d.enabled {
return nil, errDeviceNotEnabled
return nil, device.ErrPluginDisabled
}

// Due to the asynchronous nature of NvidiaPlugin, there is a possibility
Expand Down Expand Up @@ -221,7 +219,7 @@ func (d *NvidiaDevice) Reserve(deviceIDs []string) (*device.ContainerReservation
// Stats streams statistics for the detected devices.
func (d *NvidiaDevice) Stats(ctx context.Context, interval time.Duration) (<-chan *device.StatsResponse, error) {
if !d.enabled {
return nil, errDeviceNotEnabled
return nil, device.ErrPluginDisabled
}

outCh := make(chan *device.StatsResponse)
Expand Down
5 changes: 5 additions & 0 deletions plugins/device/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ const (
DeviceTypeGPU = "gpu"
)

var (
// ErrPluginDisabled indicates that the device plugin is disabled
ErrPluginDisabled = fmt.Errorf("device is not enabled")
)

// DevicePlugin is the interface for a plugin that can expose detected devices
// to Nomad and inform it how to mount them.
type DevicePlugin interface {
Expand Down

0 comments on commit 73fa874

Please sign in to comment.