diff --git a/pkg/frontend/frontend.go b/pkg/frontend/frontend.go index 445a8e7de4..3bbab8ffe2 100644 --- a/pkg/frontend/frontend.go +++ b/pkg/frontend/frontend.go @@ -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" @@ -80,6 +82,7 @@ func (cfg *Config) Validate() error { type Frontend struct { services.Service connectgrpc.GRPCRoundTripper + vcsv1connect.VCSServiceHandler frontendpb.UnimplementedFrontendForQuerierServer cfg Config @@ -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 diff --git a/pkg/frontend/frontend_vcs.go b/pkg/frontend/frontend_vcs.go deleted file mode 100644 index 8886043a4f..0000000000 --- a/pkg/frontend/frontend_vcs.go +++ /dev/null @@ -1,49 +0,0 @@ -package frontend - -import ( - "context" - - "connectrpc.com/connect" - - vcsv1 "github.com/grafana/pyroscope/api/gen/proto/go/vcs/v1" - "github.com/grafana/pyroscope/pkg/util/connectgrpc" -) - -func (f *Frontend) GithubApp( - ctx context.Context, - req *connect.Request[vcsv1.GithubAppRequest], -) (*connect.Response[vcsv1.GithubAppResponse], error) { - return connectgrpc.RoundTripUnary[vcsv1.GithubAppRequest, vcsv1.GithubAppResponse](ctx, f, req) -} - -func (f *Frontend) GithubLogin( - ctx context.Context, - req *connect.Request[vcsv1.GithubLoginRequest], -) (*connect.Response[vcsv1.GithubLoginResponse], error) { - return connectgrpc.RoundTripUnary[vcsv1.GithubLoginRequest, vcsv1.GithubLoginResponse](ctx, f, req) -} - -func (f *Frontend) GithubRefresh( - ctx context.Context, - req *connect.Request[vcsv1.GithubRefreshRequest], -) (*connect.Response[vcsv1.GithubRefreshResponse], error) { - return connectgrpc.RoundTripUnary[vcsv1.GithubRefreshRequest, vcsv1.GithubRefreshResponse](ctx, f, req) -} - -func (f *Frontend) GetFile( - ctx context.Context, - req *connect.Request[vcsv1.GetFileRequest], -) (*connect.Response[vcsv1.GetFileResponse], error) { - return connectgrpc.RoundTripUnary[vcsv1.GetFileRequest, vcsv1.GetFileResponse](ctx, f, req) -} - -func (f *Frontend) GetCommit( - ctx context.Context, - req *connect.Request[vcsv1.GetCommitRequest], -) (*connect.Response[vcsv1.GetCommitResponse], error) { - return connectgrpc.RoundTripUnary[vcsv1.GetCommitRequest, vcsv1.GetCommitResponse](ctx, f, req) -} - -func (f *Frontend) GetCommits(ctx context.Context, req *connect.Request[vcsv1.GetCommitsRequest]) (*connect.Response[vcsv1.GetCommitsResponse], error) { - return connectgrpc.RoundTripUnary[vcsv1.GetCommitsRequest, vcsv1.GetCommitsResponse](ctx, f, req) -} diff --git a/pkg/querier/vcs/client/client.go b/pkg/frontend/vcs/client/client.go similarity index 100% rename from pkg/querier/vcs/client/client.go rename to pkg/frontend/vcs/client/client.go diff --git a/pkg/querier/vcs/client/github.go b/pkg/frontend/vcs/client/github.go similarity index 100% rename from pkg/querier/vcs/client/github.go rename to pkg/frontend/vcs/client/github.go diff --git a/pkg/querier/vcs/client/metrics.go b/pkg/frontend/vcs/client/metrics.go similarity index 100% rename from pkg/querier/vcs/client/metrics.go rename to pkg/frontend/vcs/client/metrics.go diff --git a/pkg/querier/vcs/client/metrics_test.go b/pkg/frontend/vcs/client/metrics_test.go similarity index 100% rename from pkg/querier/vcs/client/metrics_test.go rename to pkg/frontend/vcs/client/metrics_test.go diff --git a/pkg/querier/vcs/commit.go b/pkg/frontend/vcs/commit.go similarity index 100% rename from pkg/querier/vcs/commit.go rename to pkg/frontend/vcs/commit.go diff --git a/pkg/querier/vcs/commit_test.go b/pkg/frontend/vcs/commit_test.go similarity index 100% rename from pkg/querier/vcs/commit_test.go rename to pkg/frontend/vcs/commit_test.go diff --git a/pkg/querier/vcs/encryption.go b/pkg/frontend/vcs/encryption.go similarity index 100% rename from pkg/querier/vcs/encryption.go rename to pkg/frontend/vcs/encryption.go diff --git a/pkg/querier/vcs/encryption_test.go b/pkg/frontend/vcs/encryption_test.go similarity index 100% rename from pkg/querier/vcs/encryption_test.go rename to pkg/frontend/vcs/encryption_test.go diff --git a/pkg/querier/vcs/github.go b/pkg/frontend/vcs/github.go similarity index 100% rename from pkg/querier/vcs/github.go rename to pkg/frontend/vcs/github.go diff --git a/pkg/querier/vcs/github_test.go b/pkg/frontend/vcs/github_test.go similarity index 100% rename from pkg/querier/vcs/github_test.go rename to pkg/frontend/vcs/github_test.go diff --git a/pkg/querier/vcs/service.go b/pkg/frontend/vcs/service.go similarity index 98% rename from pkg/querier/vcs/service.go rename to pkg/frontend/vcs/service.go index 121b5e760a..b7304373f2 100644 --- a/pkg/querier/vcs/service.go +++ b/pkg/frontend/vcs/service.go @@ -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) diff --git a/pkg/querier/vcs/source/find.go b/pkg/frontend/vcs/source/find.go similarity index 98% rename from pkg/querier/vcs/source/find.go rename to pkg/frontend/vcs/source/find.go index 4e28b2e363..4f08583d49 100644 --- a/pkg/querier/vcs/source/find.go +++ b/pkg/frontend/vcs/source/find.go @@ -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 { diff --git a/pkg/querier/vcs/source/find_go.go b/pkg/frontend/vcs/source/find_go.go similarity index 97% rename from pkg/querier/vcs/source/find_go.go rename to pkg/frontend/vcs/source/find_go.go index 7827685def..12511d3efb 100644 --- a/pkg/querier/vcs/source/find_go.go +++ b/pkg/frontend/vcs/source/find_go.go @@ -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 ( diff --git a/pkg/querier/vcs/source/find_go_test.go b/pkg/frontend/vcs/source/find_go_test.go similarity index 98% rename from pkg/querier/vcs/source/find_go_test.go rename to pkg/frontend/vcs/source/find_go_test.go index 03843cb278..3934159225 100644 --- a/pkg/querier/vcs/source/find_go_test.go +++ b/pkg/frontend/vcs/source/find_go_test.go @@ -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 { diff --git a/pkg/querier/vcs/source/golang/gen.go b/pkg/frontend/vcs/source/golang/gen.go similarity index 100% rename from pkg/querier/vcs/source/golang/gen.go rename to pkg/frontend/vcs/source/golang/gen.go diff --git a/pkg/querier/vcs/source/golang/golang.go b/pkg/frontend/vcs/source/golang/golang.go similarity index 100% rename from pkg/querier/vcs/source/golang/golang.go rename to pkg/frontend/vcs/source/golang/golang.go diff --git a/pkg/querier/vcs/source/golang/golang_test.go b/pkg/frontend/vcs/source/golang/golang_test.go similarity index 97% rename from pkg/querier/vcs/source/golang/golang_test.go rename to pkg/frontend/vcs/source/golang/golang_test.go index 28db9dede1..6ce7376b20 100644 --- a/pkg/querier/vcs/source/golang/golang_test.go +++ b/pkg/frontend/vcs/source/golang/golang_test.go @@ -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, }, diff --git a/pkg/querier/vcs/source/golang/modules.go b/pkg/frontend/vcs/source/golang/modules.go similarity index 100% rename from pkg/querier/vcs/source/golang/modules.go rename to pkg/frontend/vcs/source/golang/modules.go diff --git a/pkg/querier/vcs/source/golang/modules_test.go b/pkg/frontend/vcs/source/golang/modules_test.go similarity index 100% rename from pkg/querier/vcs/source/golang/modules_test.go rename to pkg/frontend/vcs/source/golang/modules_test.go diff --git a/pkg/querier/vcs/source/golang/packages.go b/pkg/frontend/vcs/source/golang/packages.go similarity index 100% rename from pkg/querier/vcs/source/golang/packages.go rename to pkg/frontend/vcs/source/golang/packages.go diff --git a/pkg/querier/vcs/source/golang/packages_gen.go b/pkg/frontend/vcs/source/golang/packages_gen.go similarity index 100% rename from pkg/querier/vcs/source/golang/packages_gen.go rename to pkg/frontend/vcs/source/golang/packages_gen.go diff --git a/pkg/querier/vcs/token.go b/pkg/frontend/vcs/token.go similarity index 100% rename from pkg/querier/vcs/token.go rename to pkg/frontend/vcs/token.go diff --git a/pkg/querier/vcs/token_test.go b/pkg/frontend/vcs/token_test.go similarity index 100% rename from pkg/querier/vcs/token_test.go rename to pkg/frontend/vcs/token_test.go diff --git a/pkg/phlare/modules.go b/pkg/phlare/modules.go index 1cdf21bcb5..0c3079a0ab 100644 --- a/pkg/phlare/modules.go +++ b/pkg/phlare/modules.go @@ -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" @@ -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( diff --git a/pkg/querier/grpc_handler.go b/pkg/querier/grpc_handler.go index 42d49f43f5..6512293ca7 100644 --- a/pkg/querier/grpc_handler.go +++ b/pkg/querier/grpc_handler.go @@ -4,7 +4,6 @@ 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" @@ -12,13 +11,11 @@ import ( 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() diff --git a/pkg/querier/querier.go b/pkg/querier/querier.go index ddc21d962d..939d8be135 100644 --- a/pkg/querier/querier.go +++ b/pkg/querier/querier.go @@ -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" @@ -71,8 +69,6 @@ type Querier struct { ingesterQuerier *IngesterQuerier storeGatewayQuerier *StoreGatewayQuerier - vcsv1connect.VCSServiceHandler - storageBucket phlareobj.Bucket tenantConfigProvider phlareobj.TenantConfigProvider @@ -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,