MCPcopy Index your code
hub / github.com/cortexproject/cortex / readyHandler

Method readyHandler

pkg/cortex/cortex.go:525–560  ·  view source on GitHub ↗
(sm *services.Manager)

Source from the content-addressed store, hash-verified

523}
524
525func (t *Cortex) readyHandler(sm *services.Manager) http.HandlerFunc {
526 return func(w http.ResponseWriter, r *http.Request) {
527 if !sm.IsHealthy() {
528 msg := bytes.Buffer{}
529 msg.WriteString("Some services are not Running:\n")
530
531 byState := sm.ServicesByState()
532 for st, ls := range byState {
533 fmt.Fprintf(&msg, "%v: %d\n", st, len(ls))
534 }
535
536 http.Error(w, msg.String(), http.StatusServiceUnavailable)
537 return
538 }
539
540 // Ingester has a special check that makes sure that it was able to register into the ring,
541 // and that all other ring entries are OK too.
542 if t.Ingester != nil {
543 if err := t.Ingester.CheckReady(r.Context()); err != nil {
544 http.Error(w, "Ingester not ready: "+err.Error(), http.StatusServiceUnavailable)
545 return
546 }
547 }
548
549 // Query Frontend has a special check that makes sure that a querier is attached before it signals
550 // itself as ready
551 if t.Frontend != nil {
552 if err := t.Frontend.CheckReady(r.Context()); err != nil {
553 http.Error(w, "Query Frontend not ready: "+err.Error(), http.StatusServiceUnavailable)
554 return
555 }
556 }
557
558 util.WriteTextResponse(w, "ready")
559 }
560}
561
562func (t *Cortex) setupPromQLFunctions() {
563 cortexparser.Setup(t.Cfg.Querier.EnablePromQLExperimentalFunctions, true)

Callers 1

RunMethod · 0.95

Calls 8

WriteTextResponseFunction · 0.92
WriteStringMethod · 0.80
ServicesByStateMethod · 0.80
StringMethod · 0.65
IsHealthyMethod · 0.45
ErrorMethod · 0.45
CheckReadyMethod · 0.45
ContextMethod · 0.45

Tested by

no test coverage detected