-
Notifications
You must be signed in to change notification settings - Fork 353
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
suppress health check noise #1650
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 |
---|---|---|
|
@@ -13,6 +13,7 @@ import ( | |
log "github.com/sirupsen/logrus" | ||
|
||
"github.com/zalando/skipper/eskip" | ||
"github.com/zalando/skipper/filters/accesslog" | ||
"github.com/zalando/skipper/filters/builtin" | ||
"github.com/zalando/skipper/predicates/source" | ||
) | ||
|
@@ -348,9 +349,19 @@ func shuntRoute(r *eskip.Route) { | |
} | ||
|
||
func healthcheckRoute(healthy, reverseSourcePredicate bool) *eskip.Route { | ||
status := http.StatusOK | ||
logFilters := []*eskip.Filter{{ | ||
Name: builtin.StatusName, | ||
Args: []interface{}{http.StatusOK}}, | ||
} | ||
if !healthy { | ||
status = http.StatusServiceUnavailable | ||
logFilters[0].Args = []interface{}{http.StatusServiceUnavailable} | ||
} | ||
// log if unhealthy or a debug loglevel | ||
if healthy && !log.IsLevelEnabled(log.DebugLevel) { | ||
logFilters = append(logFilters, &eskip.Filter{ | ||
Name: accesslog.DisableAccessLogName, | ||
Args: []interface{}{200}, | ||
}) | ||
Comment on lines
+352
to
+364
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. An alternative could be var healthcheckFilters []*eskip.Filter
if healthy {
if log.IsLevelEnabled(log.DebugLevel) {
healthcheckFilters, _ = eskip.ParseFilters(`status(200)`)
} else {
healthcheckFilters, _ = eskip.ParseFilters(`disableAccessLog(200) -> status(200)`)
}
} else {
healthcheckFilters, _ = eskip.ParseFilters(`status(503)`)
} adjusted testdiff --git a/dataclients/kubernetes/kube_test.go b/dataclients/kubernetes/kube_test.go
index cd899715..8a3e60f1 100644
--- a/dataclients/kubernetes/kube_test.go
+++ b/dataclients/kubernetes/kube_test.go
@@ -410,10 +410,11 @@ func checkHealthcheck(t *testing.T, got []*eskip.Route, expected, healthy, rever
return
}
- if healthy && f.Args[0] != http.StatusOK {
- t.Error("invalid healthcheck status", f.Args[0], http.StatusOK)
- } else if !healthy && f.Args[0] != http.StatusServiceUnavailable {
- t.Error("invalid healthcheck status", f.Args[0], http.StatusServiceUnavailable)
+ status := int(f.Args[0].(float64))
+ if healthy && status != http.StatusOK {
+ t.Error("invalid healthcheck status", status, http.StatusOK)
+ } else if !healthy && status != http.StatusServiceUnavailable {
+ t.Error("invalid healthcheck status", status, http.StatusServiceUnavailable)
}
return 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. This parsing functionality is awesome to know! My personal preference is to use static type compiler support whenever possible, not sure how expensive runtime parsing is but I’d expect a magnitude!? 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. It is more about readabilty, skipper parses hundreds of routes on route table update anyway. 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. We normally don’t parse filters like this in the dataclient if it’s not eskip or inline route |
||
} | ||
|
||
var p []*eskip.Predicate | ||
|
@@ -370,11 +381,8 @@ func healthcheckRoute(healthy, reverseSourcePredicate bool) *eskip.Route { | |
Id: healthcheckRouteID, | ||
Predicates: p, | ||
Path: healthcheckPath, | ||
Filters: []*eskip.Filter{{ | ||
Name: builtin.StatusName, | ||
Args: []interface{}{status}}, | ||
}, | ||
Shunt: true, | ||
Filters: logFilters, | ||
Shunt: true, | ||
} | ||
} | ||
|
||
|
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 think we can also call
logFilters
as justfilters
, because their main gig is not the logging part but the status.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.
merged