Skip to content
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

Merged
merged 1 commit into from
Dec 15, 2020
Merged

Conversation

universam1
Copy link
Contributor

This change suppresses logging of the Skipper health check path in normal conditions, reducing log noise.

The logging is enabled if the health check fails or debugging levels are enabled

This change suppresses logging of the Skipper health check path in normal conditions, reducing log noise.

The logging is enabled if the health check fails or debugging levels are enabled

Signed-off-by: Samuel Lang <[email protected]>
@universam1
Copy link
Contributor Author

@aryszka @szuecs as discussed in slack

@szuecs
Copy link
Member

szuecs commented Dec 11, 2020

👍

Comment on lines +352 to +364
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},
})
Copy link
Member

@AlexanderYastrebov AlexanderYastrebov Dec 11, 2020

Choose a reason for hiding this comment

The 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 test
diff --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
Also related to #1537

Copy link
Contributor Author

@universam1 universam1 Dec 12, 2020

Choose a reason for hiding this comment

The 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!?

Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The 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

@@ -348,9 +349,19 @@ func shuntRoute(r *eskip.Route) {
}

func healthcheckRoute(healthy, reverseSourcePredicate bool) *eskip.Route {
status := http.StatusOK
logFilters := []*eskip.Filter{{
Copy link
Contributor

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 just filters, because their main gig is not the logging part but the status.

Copy link
Member

Choose a reason for hiding this comment

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

merged

@aryszka
Copy link
Contributor

aryszka commented Dec 14, 2020

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants