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

[ADDED] Logs to healthcheck handler #2976

Merged
merged 1 commit into from
Mar 30, 2022
Merged

[ADDED] Logs to healthcheck handler #2976

merged 1 commit into from
Mar 30, 2022

Conversation

samuel-form3
Copy link
Contributor

Kubernetes probes don't use nor log the reponse body of health
endpoints. This means that for some reason a nats node running in
Kubernetes becomes on a Not Ready state we won't have a way to know why
other than to manually access the cluster and call the /healthz endpoint
manually and see the error.

This change adds an error log so we can observe what is going wrong with
a nats node that is not ready.

Signed-off-by: Samuel Torres samuel.torres@form3.tech

  • Link to issue, e.g. Resolves #NNN
  • Documentation added (if applicable)
  • Tests added
  • Branch rebased on top of current main (git pull --rebase origin main)
  • Changes squashed to a single commit (described here)
  • Build is green in Travis CI
  • You have certified that the contribution is your original work and that you license the work to the project under the Apache 2 license

Resolves #

Changes proposed in this pull request:

  • Add error logging to healthcheck endpoint

/cc @nats-io/core

@@ -2768,6 +2768,7 @@ func (s *Server) HandleHealthz(w http.ResponseWriter, r *http.Request) {

hs := s.healthz()
if hs.Error != _EMPTY_ {
s.Errorf("Healthcheck failed: %q", hs.Error)
Copy link
Member

Choose a reason for hiding this comment

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

Might suggest this be a Warnf since it can and should clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

Kubernetes probes don't use nor log the reponse body of health
endpoints. This means that for some reason a nats node running in
Kubernetes becomes on a Not Ready state we won't have a way to know why
other than to manually access the cluster and call the /healthz endpoint
manually and see the error.

This change adds an error log so we can observe what is going wrong with
a nats node that is not ready.

Signed-off-by: Samuel Torres <samuel.torres@form3.tech>
Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

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

In general LGTM, but want Ivan to weigh in as well.

@caleblloyd
Copy link
Contributor

Agree that it would be helpful - looks like Kubelet may log the response body with info logging, but the message returned up to the API server that ends up in the Pod event only gets the status code.

https://github.com/kubernetes/kubernetes/blob/3c06ef9c0c425743913df9be5bddaa86becbf0ba/pkg/probe/http/http.go#L137-L138

Copy link
Member

@kozlovic kozlovic left a comment

Choose a reason for hiding this comment

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

LGTM. No objection to this change.

@kozlovic kozlovic changed the title Add logs to healthcheck handler [ADDED] Logs to healthcheck handler Mar 30, 2022
@kozlovic kozlovic merged commit f0abf46 into nats-io:main Mar 30, 2022
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

4 participants