Skip to content

Commit 1873513

Browse files
committed
internal/rm/health: Rename getHealthCheckXids and clarify documentation
getHealthCheckXids's description is inaccurate as getHealthCheckXids actually returns the XIDs that should be ignored (not considered fatal). Exactly the opposite of what is written there. Additionally, the function name itself is a bit ambiguous thus I changed it to getDisabledHealthCheckXids. Signed-off-by: Jose Blanquicet <[email protected]>
1 parent cf6cbd9 commit 1873513

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

internal/rm/health.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const (
4242

4343
// CheckHealth performs health checks on a set of devices, writing to the 'unhealthy' channel with any unhealthy devices
4444
func (r *nvmlResourceManager) checkHealth(stop <-chan interface{}, devices Devices, unhealthy chan<- *Device) error {
45-
xids := getHealthCheckXids()
45+
xids := getDisabledHealthCheckXids()
4646
if xids.IsAllDisabled() {
4747
return nil
4848
}
@@ -61,7 +61,7 @@ func (r *nvmlResourceManager) checkHealth(stop <-chan interface{}, devices Devic
6161
}
6262
}()
6363

64-
klog.Infof("Using XIDs for health checks: %v", xids)
64+
klog.Infof("Ignoring the following XIDs for health checks: %v", xids)
6565

6666
eventSet, ret := r.nvml.EventSetCreate()
6767
if ret != nvml.SUCCESS {
@@ -206,15 +206,15 @@ func (h disabledXIDs) IsDisabled(xid uint64) bool {
206206
return h.IsAllDisabled()
207207
}
208208

209-
// getHealthCheckXids returns the XIDs that are considered fatal.
209+
// getDisabledHealthCheckXids returns the XIDs that should be ignored.
210210
// Here we combine the following (in order of precedence):
211211
// * A list of explicitly disabled XIDs (including all XIDs)
212212
// * A list of hardcoded disabled XIDs
213213
// * A list of explicitly enabled XIDs (including all XIDs)
214214
//
215215
// Note that if an XID is explicitly enabled, this takes precedence over it
216216
// having been disabled either explicitly or implicitly.
217-
func getHealthCheckXids() disabledXIDs {
217+
func getDisabledHealthCheckXids() disabledXIDs {
218218
disabled := newHealthCheckXIDs(
219219
// TODO: We should not read the envvar here directly, but instead
220220
// "upgrade" this to a top-level config option.

internal/rm/health_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func TestNewHealthCheckXIDs(t *testing.T) {
7979
}
8080
}
8181

82-
func TestGetHealthCheckXids(t *testing.T) {
82+
func TestGetDisabledHealthCheckXids(t *testing.T) {
8383
testCases := []struct {
8484
description string
8585
enabled string
@@ -209,7 +209,7 @@ func TestGetHealthCheckXids(t *testing.T) {
209209
t.Setenv(envDisableHealthChecks, tc.disabled)
210210
t.Setenv(envEnableHealthChecks, tc.enabled)
211211

212-
xids := getHealthCheckXids()
212+
xids := getDisabledHealthCheckXids()
213213
require.EqualValues(t, tc.expectedContents, xids)
214214
require.Equal(t, tc.expectedAllDisabled, xids.IsAllDisabled())
215215

0 commit comments

Comments
 (0)