Skip to content

Commit

Permalink
chore: move vcs service handler from querier to query frontend (#3709)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-p authored Nov 20, 2024
1 parent 954b967 commit 7532763
Show file tree
Hide file tree
Showing 28 changed files with 12 additions and 66 deletions.
4 changes: 4 additions & 0 deletions pkg/frontend/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ import (

"github.com/grafana/dskit/tenant"

"github.com/grafana/pyroscope/api/gen/proto/go/vcs/v1/vcsv1connect"
"github.com/grafana/pyroscope/pkg/frontend/frontendpb"
"github.com/grafana/pyroscope/pkg/frontend/vcs"
"github.com/grafana/pyroscope/pkg/querier/stats"
"github.com/grafana/pyroscope/pkg/scheduler/schedulerdiscovery"
"github.com/grafana/pyroscope/pkg/util/connectgrpc"
Expand Down Expand Up @@ -80,6 +82,7 @@ func (cfg *Config) Validate() error {
type Frontend struct {
services.Service
connectgrpc.GRPCRoundTripper
vcsv1connect.VCSServiceHandler
frontendpb.UnimplementedFrontendForQuerierServer

cfg Config
Expand Down Expand Up @@ -150,6 +153,7 @@ func NewFrontend(cfg Config, limits Limits, log log.Logger, reg prometheus.Regis
schedulerWorkers: schedulerWorkers,
schedulerWorkersWatcher: services.NewFailureWatcher(),
requests: newRequestsInProgress(),
VCSServiceHandler: vcs.New(log, reg),
}
f.GRPCRoundTripper = &realFrontendRoundTripper{frontend: f}
// Randomize to avoid getting responses from queries sent before restart, which could lead to mixing results
Expand Down
49 changes: 0 additions & 49 deletions pkg/frontend/frontend_vcs.go

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions pkg/querier/vcs/service.go → pkg/frontend/vcs/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (

vcsv1 "github.com/grafana/pyroscope/api/gen/proto/go/vcs/v1"
"github.com/grafana/pyroscope/api/gen/proto/go/vcs/v1/vcsv1connect"
"github.com/grafana/pyroscope/pkg/querier/vcs/client"
"github.com/grafana/pyroscope/pkg/querier/vcs/source"
"github.com/grafana/pyroscope/pkg/frontend/vcs/client"
"github.com/grafana/pyroscope/pkg/frontend/vcs/source"
)

var _ vcsv1connect.VCSServiceHandler = (*Service)(nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
giturl "github.com/kubescape/go-git-url"

vcsv1 "github.com/grafana/pyroscope/api/gen/proto/go/vcs/v1"
"github.com/grafana/pyroscope/pkg/querier/vcs/client"
"github.com/grafana/pyroscope/pkg/frontend/vcs/client"
)

type VCSClient interface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"golang.org/x/mod/module"

vcsv1 "github.com/grafana/pyroscope/api/gen/proto/go/vcs/v1"
"github.com/grafana/pyroscope/pkg/querier/vcs/client"
"github.com/grafana/pyroscope/pkg/querier/vcs/source/golang"
"github.com/grafana/pyroscope/pkg/frontend/vcs/client"
"github.com/grafana/pyroscope/pkg/frontend/vcs/source/golang"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
giturl "github.com/kubescape/go-git-url"
"github.com/stretchr/testify/assert"

"github.com/grafana/pyroscope/pkg/querier/vcs/client"
"github.com/grafana/pyroscope/pkg/frontend/vcs/client"
)

type VCSClientMock struct {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func TestStandardLibraryURL(t *testing.T) {
expectedOk bool
}{
{
input: "github.com/grafana/grafana/pkg/querier/vcs.go",
input: "github.com/grafana/grafana/pkg/frontend/vcs.go",
expected: "",
expectedOk: false,
},
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions pkg/phlare/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ import (
"github.com/grafana/pyroscope/pkg/frontend"
readpath "github.com/grafana/pyroscope/pkg/frontend/read_path"
queryfrontend "github.com/grafana/pyroscope/pkg/frontend/read_path/query_frontend"
"github.com/grafana/pyroscope/pkg/frontend/vcs"
"github.com/grafana/pyroscope/pkg/ingester"
objstoreclient "github.com/grafana/pyroscope/pkg/objstore/client"
"github.com/grafana/pyroscope/pkg/objstore/providers/filesystem"
"github.com/grafana/pyroscope/pkg/operations"
phlarecontext "github.com/grafana/pyroscope/pkg/phlare/context"
"github.com/grafana/pyroscope/pkg/querier"
"github.com/grafana/pyroscope/pkg/querier/vcs"
"github.com/grafana/pyroscope/pkg/querier/worker"
"github.com/grafana/pyroscope/pkg/scheduler"
"github.com/grafana/pyroscope/pkg/settings"
Expand Down Expand Up @@ -318,7 +318,6 @@ func (f *Phlare) initQuerier() (services.Service, error) {
if !f.isModuleActive(QueryFrontend) {
f.API.RegisterPyroscopeHandlers(querierSvc)
f.API.RegisterQuerierServiceHandler(querierSvc)
f.API.RegisterVCSServiceHandler(querierSvc)
}

qWorker, err := worker.NewQuerierWorker(
Expand Down
3 changes: 0 additions & 3 deletions pkg/querier/grpc_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,18 @@ import (
"net/http"

"github.com/grafana/pyroscope/api/gen/proto/go/querier/v1/querierv1connect"
vcsv1connect "github.com/grafana/pyroscope/api/gen/proto/go/vcs/v1/vcsv1connect"
connectapi "github.com/grafana/pyroscope/pkg/api/connect"
"github.com/grafana/pyroscope/pkg/util/connectgrpc"
httputil "github.com/grafana/pyroscope/pkg/util/http"
)

type QuerierSvc interface {
querierv1connect.QuerierServiceHandler
vcsv1connect.VCSServiceHandler
}

func NewGRPCHandler(svc QuerierSvc, useK6Middleware bool) connectgrpc.GRPCHandler {
mux := http.NewServeMux()
mux.Handle(querierv1connect.NewQuerierServiceHandler(svc, connectapi.DefaultHandlerOptions()...))
mux.Handle(vcsv1connect.NewVCSServiceHandler(svc, connectapi.DefaultHandlerOptions()...))

if useK6Middleware {
httpMiddleware := httputil.K6Middleware()
Expand Down
5 changes: 0 additions & 5 deletions pkg/querier/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ import (
ingestv1 "github.com/grafana/pyroscope/api/gen/proto/go/ingester/v1"
querierv1 "github.com/grafana/pyroscope/api/gen/proto/go/querier/v1"
typesv1 "github.com/grafana/pyroscope/api/gen/proto/go/types/v1"
"github.com/grafana/pyroscope/api/gen/proto/go/vcs/v1/vcsv1connect"
connectapi "github.com/grafana/pyroscope/pkg/api/connect"
"github.com/grafana/pyroscope/pkg/clientpool"
phlaremodel "github.com/grafana/pyroscope/pkg/model"
phlareobj "github.com/grafana/pyroscope/pkg/objstore"
"github.com/grafana/pyroscope/pkg/phlaredb/bucketindex"
"github.com/grafana/pyroscope/pkg/pprof"
"github.com/grafana/pyroscope/pkg/querier/vcs"
"github.com/grafana/pyroscope/pkg/storegateway"
pmath "github.com/grafana/pyroscope/pkg/util/math"
"github.com/grafana/pyroscope/pkg/util/spanlogger"
Expand Down Expand Up @@ -71,8 +69,6 @@ type Querier struct {
ingesterQuerier *IngesterQuerier
storeGatewayQuerier *StoreGatewayQuerier

vcsv1connect.VCSServiceHandler

storageBucket phlareobj.Bucket
tenantConfigProvider phlareobj.TenantConfigProvider

Expand Down Expand Up @@ -133,7 +129,6 @@ func New(params *NewQuerierParams) (*Querier, error) {
params.IngestersRing,
),
storeGatewayQuerier: storeGatewayQuerier,
VCSServiceHandler: vcs.New(params.Logger, params.Reg),
storageBucket: params.StorageBucket,
tenantConfigProvider: params.CfgProvider,
limits: params.Overrides,
Expand Down

0 comments on commit 7532763

Please sign in to comment.