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

Improvement: report unauthorized error as a health check #295

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

AdamDeHovitz
Copy link

@AdamDeHovitz AdamDeHovitz commented May 12, 2021

Before this PR

We believe we hit this case last week but it's difficult to confirm due to a lack of logging and the way an empty health status get's reported in autopilot.

After this PR

==COMMIT_MSG==
If user is unauthorized to view health checks return an unauthorized error health check rather than no health check.
==COMMIT_MSG==

Possible downsides?

Possibly confusing to users/might interact poorly if existing monitoring/error catching depends on an empty health status object.


This change is Reviewable

@AdamDeHovitz AdamDeHovitz requested a review from nmiyake May 12, 2021 17:58
@@ -66,7 +74,7 @@ func (h *healthHandlerImpl) computeNewHealthStatus(req *http.Request) (health.He
if sharedSecret := h.healthCheckSharedSecret.CurrentString(); sharedSecret != "" {
token, err := httpserver.ParseBearerTokenHeader(req)
if err != nil || sharedSecret != token {
return health.HealthStatus{}, http.StatusUnauthorized
return healthStatusUnauthorized, http.StatusUnauthorized
Copy link
Author

Choose a reason for hiding this comment

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

My preference was to log when we hit this case but there's no accessible ctx and the loggingHealthStatusChangeHandler used above derives the status code from the health status rather than from the status returned by computeNewHealthStatus

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.

None yet

1 participant