Skip to content

Commit

Permalink
Support for health check (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
krishnasrinivas authored Jan 22, 2021
1 parent 8b756d8 commit 1b8a9a1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,5 @@ kubectl logs -f --namespace spark-operator spark-minio-app-driver spark-kubernet
- Sidekick cache honors standard HTTP caching policies such as 'Cache-Control', 'Expiry' etc. specified in request and response directives.

- GET requests with Range headers are not cached to keep the codebase simple.

- Health-Check: Health check is provided at the path "/v1/health". It returns "200 OK" even if any one of the sites is reachable, else it returns "502 Bad Gateway" error.
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ import (

const slashSeparator = "/"

const healthCheckPath = "/v1/health"

var (
globalQuietEnabled bool
globalDebugEnabled bool
Expand Down Expand Up @@ -339,6 +341,10 @@ func (m *multisite) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Server", "SideKick/"+pkg.ReleaseTag) // indicate sidekick is serving the request
for _, s := range m.sites {
if s.Online() {
if r.URL.Path == healthCheckPath {
// Health check endpoint should return success
return
}
s.ServeHTTP(w, r)
return
}
Expand Down

0 comments on commit 1b8a9a1

Please sign in to comment.