(sm *services.Manager)
| 523 | } |
| 524 | |
| 525 | func (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 | |
| 562 | func (t *Cortex) setupPromQLFunctions() { |
| 563 | cortexparser.Setup(t.Cfg.Querier.EnablePromQLExperimentalFunctions, true) |
no test coverage detected