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

Add healthz checker #31

Merged
merged 1 commit into from
Nov 29, 2016
Merged

Add healthz checker #31

merged 1 commit into from
Nov 29, 2016

Conversation

aledbf
Copy link
Member

@aledbf aledbf commented Nov 27, 2016

fixes #27

@coveralls
Copy link

Coverage Status

Coverage remained the same at 40.231% when pulling 2fb0c3db17625eec3881c400c1e0967b2dc3a0ba on aledbf:health-check into d1fb96a on kubernetes:master.

Copy link
Contributor

@bprashanth bprashanth left a comment

Choose a reason for hiding this comment

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

I assume all our yaml exposes a probe through a standard port, and the output of this health method call is automatically exported via http endpoint on that port by the generic_controller?

I also think you need to update the comment in doc.go since we've added a new interface method?


// Check returns if the nginx healthz endpoint is returning ok (status code 200)
func (n NGINXController) Check(_ *http.Request) error {
res, err := http.Get("http://127.0.0.1:18080/healthz")
Copy link
Contributor

Choose a reason for hiding this comment

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

are we exposing the output of a Check call on some standard port as a liveness or readiness check?

Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -40,6 +41,10 @@ var (
// Controller holds the methods to handle an Ingress backend
// TODO (#18): Make sure this is sufficiently supportive of other backends.
type Controller interface {
// HealthzChecker returns is a named healthz check that returns the ingress
// controller status
healthz.HealthzChecker
Copy link
Contributor

Choose a reason for hiding this comment

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

please clarify what happens if the check is +ve/-ve

Copy link
Contributor

Choose a reason for hiding this comment

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

actually i prefer giving this interface a plain Check method, the name "healthz" implies a http endpoint and the Check method call may do anything else to validate health

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm embedding the interface not using healthz as name (not sure what's the issue here)

Copy link
Contributor

Choose a reason for hiding this comment

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

If the only purpose of the healthzChecker is to have a Check method, it should be renamed to healthChecker. If that is not the case (i.e healthzChecker is an interface for especially http health checks), we shouldn't embed it, because adding methods to healthzChecker will directly bubble up here. Reading the interface definition one could get tricked into thinking that all backends must return a http error from the Check() call, when that's not the case. The inclusion of z in the name leads to unnecessary confusion IMO.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh sorry, I missed that Check() actually takes a url. Does it need to? What if I want to ps aux | grep nginx as a health check in my backend?

Copy link
Member Author

@aledbf aledbf Nov 27, 2016

Choose a reason for hiding this comment

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

What if I want to ps aux | grep nginx as a health check in my backend?

you can do that inside the Check method of you backend.
Just in case no matter what/how you backend is checking the yaml always remains like this:

        readinessProbe:
          httpGet:
            path: /healthz
            port: 10254
            scheme: HTTP
        livenessProbe:
          httpGet:
            path: /healthz
            port: 10254
            scheme: HTTP

In nginx I know that the URL exposed in the nginx default server http://127.0.0.1:18080/healthz tells me if nginx is running or not

Copy link
Contributor

Choose a reason for hiding this comment

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

Right I'm asking why "Check(_ *http.Request) error" vs "Check() error", since check is not restricted to http anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 27, 2016
@aledbf
Copy link
Member Author

aledbf commented Nov 27, 2016

I also think you need to update the comment in doc.go since we've added a new interface method?

done

@coveralls
Copy link

Coverage Status

Coverage increased (+0.005%) to 40.236% when pulling d49579e9b4c6a1c9b88317a9bf12d1f4f7546fac on aledbf:health-check into d1fb96a on kubernetes:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.08%) to 40.148% when pulling 478d51c on aledbf:health-check into d1fb96a on kubernetes:master.

@bprashanth
Copy link
Contributor

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove hardcoded health check from GenericController
4 participants