Skip to content

Commit feefa81

Browse files
authored
fix: readiness check for ingesters and frontend (grafana#3435)
1 parent 336b7dd commit feefa81

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

Makefile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,10 @@ build: frontend/build go/bin ## Do a production build (requiring the frontend bu
7777
build-dev: ## Do a dev build (without requiring the frontend)
7878
$(MAKE) EMBEDASSETS="" go/bin
7979

80-
.PHONY: frontend/build
81-
frontend/build: frontend/deps ## Do a production build for the frontend
82-
yarn build
8380

84-
.PHONY: frontend/deps
85-
frontend/deps:
86-
yarn --frozen-lockfile
81+
.PHONY: frontend/build
82+
frontend/build:
83+
docker build -f cmd/pyroscope/frontend.Dockerfile --output=public/build .
8784

8885
.PHONY: release
8986
release/prereq: $(BIN)/goreleaser ## Ensure release pre requesites are met

cmd/pyroscope/frontend.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:18 as builder
1+
FROM node:18 AS builder
22
RUN apt-get update && apt-get install -y libpango1.0-dev libcairo2-dev
33
WORKDIR /pyroscope
44
COPY yarn.lock package.json tsconfig.json ./

pkg/phlare/modules.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ func (f *Phlare) initQueryFrontend() (services.Service, error) {
109109
f.API.RegisterPyroscopeHandlers(frontendSvc)
110110
f.API.RegisterQueryFrontend(frontendSvc)
111111
f.API.RegisterQuerier(frontendSvc)
112+
f.frontend = frontendSvc
112113

113114
return frontendSvc, nil
114115
}
@@ -408,6 +409,7 @@ func (f *Phlare) initIngester() (_ services.Service, err error) {
408409
}
409410

410411
f.API.RegisterIngester(svc)
412+
f.ingester = svc
411413

412414
return svc, nil
413415
}

pkg/phlare/phlare.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,9 @@ type Phlare struct {
239239

240240
grpcGatewayMux *grpcgw.ServeMux
241241

242-
auth connect.Option
242+
auth connect.Option
243+
ingester *ingester.Ingester
244+
frontend *frontend.Frontend
243245
}
244246

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

507+
if f.ingester != nil {
508+
if err := f.ingester.CheckReady(r.Context()); err != nil {
509+
http.Error(w, "Ingester not ready: "+err.Error(), http.StatusServiceUnavailable)
510+
return
511+
}
512+
}
513+
514+
if f.frontend != nil {
515+
if err := f.frontend.CheckReady(r.Context()); err != nil {
516+
http.Error(w, "Query Frontend not ready: "+err.Error(), http.StatusServiceUnavailable)
517+
return
518+
}
519+
}
520+
505521
util.WriteTextResponse(w, "ready")
506522
}
507523
}

0 commit comments

Comments
 (0)