Skip to content
Closed
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
13 changes: 7 additions & 6 deletions pkg/device-plugin/nvidiadevice/nvinternal/rm/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (

"github.com/NVIDIA/go-nvml/pkg/nvml"
"k8s.io/klog/v2"
kubeletdevicepluginv1beta1 "k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1"
)

const (
Expand All @@ -56,8 +57,8 @@ const (
envEnableHealthChecks = "DP_ENABLE_HEALTHCHECKS"
)

// CheckHealth performs health checks on a set of devices, writing to the 'unhealthy' channel with any unhealthy devices
func (r *nvmlResourceManager) checkHealth(stop <-chan interface{}, devices Devices, unhealthy chan<- *Device, disableNVML <-chan bool) error {
// CheckHealth performs health checks on a set of devices, writing to the 'health' channel with any unhealthy devices
func (r *nvmlResourceManager) checkHealth(stop <-chan interface{}, devices Devices, health chan<- *Device, disableNVML <-chan bool) error {
Comment thread
coderabbitai[bot] marked this conversation as resolved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the rename stops at the sig, l.102/112/119 still send to unhealthy so this pkg doesn't compile.

xids := getHealthCheckXids()
if xids.IsAllDisabled() {
return nil
Expand Down Expand Up @@ -123,7 +124,7 @@ func (r *nvmlResourceManager) checkHealth(stop <-chan interface{}, devices Devic
}
if ret != nvml.SUCCESS {
klog.Infof("Marking device %v as unhealthy: %v", d.ID, ret)
unhealthy <- d
health <- d
}
}

Expand All @@ -146,7 +147,7 @@ func (r *nvmlResourceManager) checkHealth(stop <-chan interface{}, devices Devic
if ret != nvml.SUCCESS {
klog.Infof("Error waiting for event: %v; Marking all devices as unhealthy", ret)
for _, d := range devices {
unhealthy <- d
health <- d
}
continue
}
Expand All @@ -167,7 +168,7 @@ func (r *nvmlResourceManager) checkHealth(stop <-chan interface{}, devices Devic
// If we cannot reliably determine the device UUID, we mark all devices as unhealthy.
klog.Infof("Failed to determine uuid for event %v: %v; Marking all devices as unhealthy.", e, ret)
for _, d := range devices {
unhealthy <- d
health <- d
}
continue
}
Expand All @@ -188,7 +189,7 @@ func (r *nvmlResourceManager) checkHealth(stop <-chan interface{}, devices Devic
}

klog.Infof("XidCriticalError: Xid=%d on Device=%s; marking device as unhealthy.", e.EventData, d.ID)
unhealthy <- d
health <- d
}
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/device-plugin/nvidiadevice/nvinternal/rm/nvml_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ func (r *nvmlResourceManager) GetDevicePaths(ids []string) []string {
return append(paths, r.Devices().Subset(ids).GetPaths()...)
}

// CheckHealth performs health checks on a set of devices, writing to the 'unhealthy' channel with any unhealthy devices
func (r *nvmlResourceManager) CheckHealth(stop <-chan interface{}, unhealthy chan<- *Device, disableNVML <-chan bool, ackDisableHealthChecks chan<- bool) error {
// CheckHealth performs health checks on a set of devices, writing to the 'health' channel with device health updates or transitions.
func (r *nvmlResourceManager) CheckHealth(stop <-chan interface{}, health chan<- *Device, disableNVML <-chan bool, ackDisableHealthChecks chan<- bool) error {
for {
// first check if disableNVML channel signal is pass close into checkHealth function
// if signal is pass close, return error "close signal received"
err := r.checkHealth(stop, r.devices, unhealthy, disableNVML)
err := r.checkHealth(stop, r.devices, health, disableNVML)
// checkHealth returns nil when health checks are disabled or on shutdown.
if err != nil && err.Error() == "close signal received" {
ackDisableHealthChecks <- true
Expand Down
2 changes: 1 addition & 1 deletion pkg/device-plugin/nvidiadevice/nvinternal/rm/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type ResourceManager interface {
Devices() Devices
GetDevicePaths([]string) []string
GetPreferredAllocation(available, required []string, size int) ([]string, error)
CheckHealth(stop <-chan interface{}, unhealthy chan<- *Device, disableNVML <-chan bool, ackDisableHealthChecks chan<- bool) error
CheckHealth(stop <-chan interface{}, health chan<- *Device, disableNVML <-chan bool, ackDisableHealthChecks chan<- bool) error
ValidateRequest(AnnotatedIDs) error
}

Expand Down
24 changes: 12 additions & 12 deletions pkg/device-plugin/nvidiadevice/nvinternal/rm/rm_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var _ ResourceManager = &ResourceManagerMock{}
//
// // make and configure a mocked ResourceManager
// mockedResourceManager := &ResourceManagerMock{
// CheckHealthFunc: func(stop <-chan interface{}, unhealthy chan<- *Device) error {
// CheckHealthFunc: func(stop <-chan interface{}, health chan<- *Device) error {
// panic("mock out the CheckHealth method")
// },
// DevicesFunc: func() Devices {
Expand All @@ -74,7 +74,7 @@ var _ ResourceManager = &ResourceManagerMock{}
// }
type ResourceManagerMock struct {
// CheckHealthFunc mocks the CheckHealth method.
CheckHealthFunc func(stop <-chan interface{}, unhealthy chan<- *Device) error
CheckHealthFunc func(stop <-chan interface{}, health chan<- *Device) error

// DevicesFunc mocks the Devices method.
DevicesFunc func() Devices
Expand All @@ -97,8 +97,8 @@ type ResourceManagerMock struct {
CheckHealth []struct {
// Stop is the stop argument value.
Stop <-chan interface{}
// Unhealthy is the unhealthy argument value.
Unhealthy chan<- *Device
// Health is the health argument value.
Health chan<- *Device
}
// Devices holds details about calls to the Devices method.
Devices []struct {
Expand Down Expand Up @@ -135,13 +135,13 @@ type ResourceManagerMock struct {
}

// CheckHealth calls CheckHealthFunc.
func (mock *ResourceManagerMock) CheckHealth(stop <-chan interface{}, unhealthy chan<- *Device, disableNVML <-chan bool, ackDisableHealthChecks chan<- bool) error {
func (mock *ResourceManagerMock) CheckHealth(stop <-chan interface{}, health chan<- *Device, disableNVML <-chan bool, ackDisableHealthChecks chan<- bool) error {
callInfo := struct {
Stop <-chan interface{}
Unhealthy chan<- *Device
Stop <-chan interface{}
Health chan<- *Device
}{
Stop: stop,
Unhealthy: unhealthy,
Stop: stop,
Health: health,
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
mock.lockCheckHealth.Lock()
mock.calls.CheckHealth = append(mock.calls.CheckHealth, callInfo)
Expand All @@ -152,16 +152,16 @@ func (mock *ResourceManagerMock) CheckHealth(stop <-chan interface{}, unhealthy
)
return errOut
}
return mock.CheckHealthFunc(stop, unhealthy)
return mock.CheckHealthFunc(stop, health)
}

// CheckHealthCalls gets all the calls that were made to CheckHealth.
// Check the length with:
//
// len(mockedResourceManager.CheckHealthCalls())
func (mock *ResourceManagerMock) CheckHealthCalls() []struct {
Stop <-chan interface{}
Unhealthy chan<- *Device
Stop <-chan interface{}
Health chan<- *Device
} {
var calls []struct {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this local still says Unhealthy while the return type above says Health, so it doesn't compile.

Stop <-chan interface{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ func (r *tegraResourceManager) GetDevicePaths(ids []string) []string {
}

// CheckHealth is disabled for the tegraResourceManager
func (r *tegraResourceManager) CheckHealth(stop <-chan interface{}, unhealthy chan<- *Device, disableNVML <-chan bool, ackDisableHealthChecks chan<- bool) error {
func (r *tegraResourceManager) CheckHealth(stop <-chan interface{}, health chan<- *Device, disableNVML <-chan bool, ackDisableHealthChecks chan<- bool) error {
return nil
}
Loading