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

etcdhttp/metrics.go: exclude alarms from health check conditionally with ?exclude=NOSPACE #12880

Merged
merged 2 commits into from
Apr 21, 2021

Conversation

chaochn47
Copy link
Member

@chaochn47 chaochn47 commented Apr 20, 2021

Overview

Exclude alarms from health check with ?exclude=NOSPACE

Similar to kubernetes excludes specific checks
https://kubernetes.io/docs/reference/using-api/health-checks/#api-endpoints-for-health

curl -k 'https://localhost:6443/readyz?verbose&exclude=etcd'

The motivation is to exclude NOSPACE alarms in etcd supervisor or peer to peer health checks.

Testing

Added unit test against serverV2 to verify the logic due to v3 *etcdserver.EtcdServer is hard to mock out.

Unit test output

go test -v -run TestHealthHandler -mod=readonly
=== RUN   TestHealthHandler
{"level":"debug","msg":"serving /health true"}
{"level":"debug","msg":"/health OK","status-code":200}
{"level":"warn","msg":"serving /health false due to an alarm","alarm":"alarm:NOSPACE "}
{"level":"warn","msg":"/health error","output":"{\"health\":\"false\",\"reason\":\"ALARM NOSPACE\"}","status-code":503}
{"level":"debug","msg":"/health excluded alarm","alarm":"NOSPACE"}
{"level":"debug","msg":"serving /health true"}
{"level":"debug","msg":"/health OK","status-code":200}
{"level":"warn","msg":"fail exclude alarms from health check","exclude alarms":"map[NOSPACE:{}]"}
{"level":"debug","msg":"serving /health true"}
{"level":"debug","msg":"/health OK","status-code":200}
{"level":"debug","msg":"/health excluded alarm","alarm":"NOSPACE"}
{"level":"warn","msg":"serving /health false due to an alarm","alarm":"memberID:1 alarm:CORRUPT "}
{"level":"warn","msg":"/health error","output":"{\"health\":\"false\",\"reason\":\"ALARM CORRUPT\"}","status-code":503}
{"level":"debug","msg":"/health excluded alarm","alarm":"NOSPACE"}
{"level":"debug","msg":"/health excluded alarm","alarm":"CORRUPT"}
{"level":"debug","msg":"serving /health true"}
{"level":"debug","msg":"/health OK","status-code":200}
--- PASS: TestHealthHandler (0.01s)
PASS
ok      go.etcd.io/etcd/server/v3/etcdserver/api/etcdhttp       0.120s

@chaochn47
Copy link
Member Author

@gyuho PTAL, thanks!!

@chaochn47 chaochn47 changed the title etcdhttp/metrics.go: exclude alarms from health check with ?exclude=NOSPACE etcdhttp/metrics.go: exclude alarms from health check conditionally with ?exclude=NOSPACE Apr 20, 2021
@chaochn47 chaochn47 force-pushed the exclude_alarms_from_health_check branch from 8837eff to 6fd1e64 Compare April 20, 2021 18:02
@chaochn47 chaochn47 force-pushed the exclude_alarms_from_health_check branch from 6fd1e64 to b321c48 Compare April 20, 2021 20:17
Copy link
Contributor

@gyuho gyuho left a comment

Choose a reason for hiding this comment

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

lgtm

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

Successfully merging this pull request may close these issues.

3 participants