Skip to content

Commit 8011678

Browse files
authored
Merge pull request #164 from weaveworks/ready-handler
Add ready handler back in
2 parents 79462f9 + 393be5a commit 8011678

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

cmd/cortex/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ func setupIngester(
316316
log.Fatal(err)
317317
}
318318
prometheus.MustRegister(ingester)
319+
320+
router.Path("/ready").Handler(http.HandlerFunc(ingester.ReadinessHandler))
319321
return ingester
320322
}
321323

ingester/http_server.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package ingester
2+
3+
import (
4+
"net/http"
5+
)
6+
7+
// ReadinessHandler returns 204 when the ingester is ready,
8+
// 500 otherwise. It's used by kubernetes to indicate if the ingester
9+
// pool is ready to have ingesters added / removed.
10+
func (i *Ingester) ReadinessHandler(w http.ResponseWriter, r *http.Request) {
11+
if i.Ready() {
12+
w.WriteHeader(http.StatusNoContent)
13+
} else {
14+
w.WriteHeader(http.StatusInternalServerError)
15+
}
16+
}

0 commit comments

Comments
 (0)