-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Small code enhancements #3712
Small code enhancements #3712
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[linters-settings] | ||
|
||
[linters-settings.govet] | ||
check-shadowing = true | ||
|
||
[linters-settings.golint] | ||
min-confidence = 0.0 | ||
|
||
[linters-settings.gocyclo] | ||
min-complexity = 22.0 | ||
|
||
[linters-settings.maligned] | ||
suggest-new = true | ||
|
||
[linters-settings.goconst] | ||
min-len = 2.0 | ||
min-occurrences = 2.0 | ||
|
||
[linters-settings.misspell] | ||
locale = "US" | ||
|
||
[linters] | ||
enable-all = true | ||
disable = [ | ||
"maligned", | ||
"lll", | ||
"gas", | ||
"dupl", | ||
"prealloc" | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,30 +130,34 @@ func (hc *HealthCheck) execute(ctx context.Context, backend *BackendConfig) { | |
func (hc *HealthCheck) checkBackend(backend *BackendConfig) { | ||
enabledURLs := backend.LB.Servers() | ||
var newDisabledURLs []*url.URL | ||
for _, url := range backend.disabledURLs { | ||
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. Is there a particular reason to make the variable name a single letter instead of a noun? 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. because 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. Is 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. Has been changed into 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. 👍 |
||
for _, disableURL := range backend.disabledURLs { | ||
serverUpMetricValue := float64(0) | ||
if err := checkHealth(url, backend); err == nil { | ||
log.Warnf("Health check up: Returning to server list. Backend: %q URL: %q", backend.name, url.String()) | ||
backend.LB.UpsertServer(url, roundrobin.Weight(1)) | ||
if err := checkHealth(disableURL, backend); err == nil { | ||
log.Warnf("Health check up: Returning to server list. Backend: %q URL: %q", backend.name, disableURL.String()) | ||
if err := backend.LB.UpsertServer(disableURL, roundrobin.Weight(1)); err != nil { | ||
log.Error(err) | ||
} | ||
serverUpMetricValue = 1 | ||
} else { | ||
log.Warnf("Health check still failing. Backend: %q URL: %q Reason: %s", backend.name, url.String(), err) | ||
newDisabledURLs = append(newDisabledURLs, url) | ||
log.Warnf("Health check still failing. Backend: %q URL: %q Reason: %s", backend.name, disableURL.String(), err) | ||
newDisabledURLs = append(newDisabledURLs, disableURL) | ||
} | ||
labelValues := []string{"backend", backend.name, "url", url.String()} | ||
labelValues := []string{"backend", backend.name, "url", disableURL.String()} | ||
hc.metrics.BackendServerUpGauge().With(labelValues...).Set(serverUpMetricValue) | ||
} | ||
backend.disabledURLs = newDisabledURLs | ||
|
||
for _, url := range enabledURLs { | ||
for _, enableURL := range enabledURLs { | ||
serverUpMetricValue := float64(1) | ||
if err := checkHealth(url, backend); err != nil { | ||
log.Warnf("Health check failed: Remove from server list. Backend: %q URL: %q Reason: %s", backend.name, url.String(), err) | ||
backend.LB.RemoveServer(url) | ||
backend.disabledURLs = append(backend.disabledURLs, url) | ||
if err := checkHealth(enableURL, backend); err != nil { | ||
log.Warnf("Health check failed: Remove from server list. Backend: %q URL: %q Reason: %s", backend.name, enableURL.String(), err) | ||
if err := backend.LB.RemoveServer(enableURL); err != nil { | ||
log.Error(err) | ||
} | ||
backend.disabledURLs = append(backend.disabledURLs, enableURL) | ||
serverUpMetricValue = 0 | ||
} | ||
labelValues := []string{"backend", backend.name, "url", url.String()} | ||
labelValues := []string{"backend", backend.name, "url", enableURL.String()} | ||
hc.metrics.BackendServerUpGauge().With(labelValues...).Set(serverUpMetricValue) | ||
} | ||
} | ||
|
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.
So we target 🇺🇸English instead of 🇬🇧 English right? (I see the same for behavior also)
Not a blocking thing nor to be changed. Just wanted to check :)
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.
Yes exactly
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.
👍