-
Notifications
You must be signed in to change notification settings - Fork 828
refactor: upgrade health check config from env vars to top-level options #2151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,7 @@ | |
|
|
||
| import ( | ||
| "fmt" | ||
| "os" | ||
| "strconv" | ||
| "strings" | ||
|
|
||
|
|
@@ -58,7 +58,7 @@ | |
|
|
||
| // 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 { | ||
| xids := getHealthCheckXids() | ||
| xids := getHealthCheckXids(r.disableHealthChecks, r.enableHealthChecks) | ||
|
shellyco-code marked this conversation as resolved.
|
||
| if xids.IsAllDisabled() { | ||
| return nil | ||
| } | ||
|
|
@@ -228,23 +228,18 @@ | |
| } | ||
|
|
||
| // getHealthCheckXids returns the XIDs that are considered fatal. | ||
| // Here we combine the following (in order of precedence): | ||
| // * A list of explicitly disabled XIDs (including all XIDs) | ||
| // * A list of hardcoded disabled XIDs | ||
| // * A list of explicitly enabled XIDs (including all XIDs) | ||
| // | ||
| // Note that if an XID is explicitly enabled, this takes precedence over it | ||
| // having been disabled either explicitly or implicitly. | ||
| func getHealthCheckXids() disabledXIDs { | ||
| // Healthchecks can be disabled by specifying an explicit list of XIDs to ignore. | ||
| // This list is defined by the DP_DISABLE_HEALTHCHECKS and DP_ENABLE_HEALTHCHECKS configuration options. | ||
| // If DP_DISABLE_HEALTHCHECKS="all", all healthchecks are disabled. | ||
| // An XID that is present in the "enabled" list will override the "disabled" list. | ||
| // The list of ignored XIDs returned contains the predefined list of application errors | ||
| // in addition to the specified list, minus the XIDs from the "enabled" list. | ||
| func getHealthCheckXids(disableHealthChecks, enableHealthChecks string) disabledXIDs { | ||
| disabled := newHealthCheckXIDs( | ||
| // TODO: We should not read the envvar here directly, but instead | ||
| // "upgrade" this to a top-level config option. | ||
| strings.Split(strings.ToLower(os.Getenv(envDisableHealthChecks)), ",")..., | ||
| strings.Split(strings.ToLower(disableHealthChecks), ",")..., | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the os import at the top is unused now that both getenv calls are gone so the pkg doesnt compile, can u drop it?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! Dropped the unused os import in health.go |
||
| ) | ||
| enabled := newHealthCheckXIDs( | ||
| // TODO: We should not read the envvar here directly, but instead | ||
| // "upgrade" this to a top-level config option. | ||
| strings.Split(strings.ToLower(os.Getenv(envEnableHealthChecks)), ",")..., | ||
| strings.Split(strings.ToLower(enableHealthChecks), ",")..., | ||
| ) | ||
|
|
||
| // Add the list of hardcoded disabled (ignored) XIDs: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the env names are hardcoded here (4 times) while envDisableHealthChecks/envEnableHealthChecks in rm/health.go are now dead, can u export those consts and read the env once before the switch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I exported EnvDisableHealthChecks and EnvEnableHealthChecks in health.go and refactored getResourceManagers to read them just once at the top before the switch statement