Skip to content

Commit

Permalink
fix: readiness check for ingesters and frontend (#3435)
Browse files Browse the repository at this point in the history
  • Loading branch information
korniltsev authored Jul 22, 2024
1 parent 336b7dd commit feefa81
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
9 changes: 3 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,10 @@ build: frontend/build go/bin ## Do a production build (requiring the frontend bu
build-dev: ## Do a dev build (without requiring the frontend)
$(MAKE) EMBEDASSETS="" go/bin

.PHONY: frontend/build
frontend/build: frontend/deps ## Do a production build for the frontend
yarn build

.PHONY: frontend/deps
frontend/deps:
yarn --frozen-lockfile
.PHONY: frontend/build
frontend/build:
docker build -f cmd/pyroscope/frontend.Dockerfile --output=public/build .

.PHONY: release
release/prereq: $(BIN)/goreleaser ## Ensure release pre requesites are met
Expand Down
2 changes: 1 addition & 1 deletion cmd/pyroscope/frontend.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18 as builder
FROM node:18 AS builder
RUN apt-get update && apt-get install -y libpango1.0-dev libcairo2-dev
WORKDIR /pyroscope
COPY yarn.lock package.json tsconfig.json ./
Expand Down
2 changes: 2 additions & 0 deletions pkg/phlare/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func (f *Phlare) initQueryFrontend() (services.Service, error) {
f.API.RegisterPyroscopeHandlers(frontendSvc)
f.API.RegisterQueryFrontend(frontendSvc)
f.API.RegisterQuerier(frontendSvc)
f.frontend = frontendSvc

return frontendSvc, nil
}
Expand Down Expand Up @@ -408,6 +409,7 @@ func (f *Phlare) initIngester() (_ services.Service, err error) {
}

f.API.RegisterIngester(svc)
f.ingester = svc

return svc, nil
}
Expand Down
18 changes: 17 additions & 1 deletion pkg/phlare/phlare.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ type Phlare struct {

grpcGatewayMux *grpcgw.ServeMux

auth connect.Option
auth connect.Option
ingester *ingester.Ingester
frontend *frontend.Frontend
}

func New(cfg Config) (*Phlare, error) {
Expand Down Expand Up @@ -502,6 +504,20 @@ func (f *Phlare) readyHandler(sm *services.Manager) http.HandlerFunc {
return
}

if f.ingester != nil {
if err := f.ingester.CheckReady(r.Context()); err != nil {
http.Error(w, "Ingester not ready: "+err.Error(), http.StatusServiceUnavailable)
return
}
}

if f.frontend != nil {
if err := f.frontend.CheckReady(r.Context()); err != nil {
http.Error(w, "Query Frontend not ready: "+err.Error(), http.StatusServiceUnavailable)
return
}
}

util.WriteTextResponse(w, "ready")
}
}
Expand Down

0 comments on commit feefa81

Please sign in to comment.