-
Notifications
You must be signed in to change notification settings - Fork 118
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 /_/health endpoint to of-watchdog #13
Conversation
requesthandler_test.go
Outdated
|
||
func removeLockFile() error { | ||
path := filepath.Join(os.TempDir(), ".lock") | ||
log.Printf("Removing lock-file : %s\n", path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't encourage logging messages in tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are methods in the testing
package for this. t.Log
and t.Logf
which only get printed when a test fails or the -test.v
flag is set. See here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed the log statement.
I think this looks fine. @johnmccabe can you comment? |
main.go
Outdated
func makeHealthHandler() func(w http.ResponseWriter, r *http.Request) { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
switch r.Method { | ||
case "GET": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use http.MethodGet
here for consistency with the existing watchdog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree .. I have updated this.
return true | ||
} | ||
|
||
func makeHealthHandler() func(w http.ResponseWriter, r *http.Request) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this not be the same as the old watchdog implementation? The acceptingConnections
check is missing here and from the lock()
function. Why is that no longer needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The acceptingConnections
check is part of the graceful shutdown that's currently only in the original watchdog. There's an issue to port it over here: #10
I'm starting to work on that. Hoping to have a PR tonight (US time)
b7f9981
to
0dfbe9e
Compare
Introduce new endpoint `/_/health` to watchdog for health status of functions which checks for `/tmp/.lock` file Added tests for healthHandler Issues: openfaas/faas#547 Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
0dfbe9e
to
390f6ac
Compare
Lgtm 👍 |
Introduce new endpoint
/_/health
to watchdog for health status offunctions which checks for
/tmp/.lock
fileAdded tests for healthHandler
Issues: openfaas/faas#547
Signed-off-by: Vivek Singh vivekkmr45@yahoo.in
Description
Motivation and Context
Issue raised by Alex: Watchdog: introduce endpoints for health and metrics faas#547
How Has This Been Tested?
This has been tested on Mac by building the watchdog binary.
Types of changes
Checklist:
git commit -s