Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused frontend scheduler code #1734

Merged
merged 4 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
compactor.compaction.flush_size_bytes. [#1696](https://github.com/grafana/tempo/pull/1696) (@joe-elliott)
* [CHANGE] Return 200 instead of 206 when blocks failed is < tolerate_failed_blocks. [#1725](https://github.com/grafana/tempo/pull/1725) (@joe-elliott)
* [CHANGE] Update Go to 1.19 [#1665](https://github.com/grafana/tempo/pull/1665) (@ie-pham)
* [CHANGE] Remove unsued scheduler frontend code [#1734](https://github.com/grafana/tempo/pull/1734) (@mapno)
* [FEATURE] Add capability to configure the used S3 Storage Class [#1697](https://github.com/grafana/tempo/pull/1714) (@amitsetty)
* [ENHANCEMENT] cache: expose username and sentinel_username redis configuration options for ACL-based Redis Auth support [#1708](https://github.com/grafana/tempo/pull/1708) (@jsievenpiper)
* [ENHANCEMENT] metrics-generator: expose span size as a metric [#1662](https://github.com/grafana/tempo/pull/1662) (@ie-pham)
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GOPATH := $(shell go env GOPATH)
GORELEASER := $(GOPATH)/bin/goreleaser

# Build Images
DOCKER_PROTOBUF_IMAGE ?= otel/build-protobuf:0.2.1
DOCKER_PROTOBUF_IMAGE ?= otel/build-protobuf:0.14.0
FLATBUFFERS_IMAGE ?= neomantra/flatbuffers
LOKI_BUILD_IMAGE ?= grafana/loki-build-image:0.21.0
DOCS_IMAGE ?= grafana/docs-base:latest
Expand Down Expand Up @@ -184,7 +184,6 @@ gen-proto:
$(call PROTO_GEN,$(PROTO_INTERMEDIATE_DIR)/trace/v1/trace.proto,./pkg/tempopb/)
$(call PROTO_GEN,pkg/tempopb/tempo.proto,./)
$(call PROTO_GEN_WITH_VENDOR,modules/frontend/v1/frontendv1pb/frontend.proto,./)
$(call PROTO_GEN_WITH_VENDOR,modules/frontend/v2/frontendv2pb/frontend.proto,./)

rm -rf $(PROTO_INTERMEDIATE_DIR)

Expand Down
6 changes: 3 additions & 3 deletions cmd/tempo/app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ func (t *App) initQuerier() (services.Service, error) {
}

func (t *App) initQueryFrontend() (services.Service, error) {
// cortexTripper is a bridge between http and httpgrpc. it does the job of passing data to the cortex
// frontend code
cortexTripper, v1, _, err := frontend.InitFrontend(t.cfg.Frontend.Config, frontend.CortexNoQuerierLimits{}, 0, log.Logger, prometheus.DefaultRegisterer)
// cortexTripper is a bridge between http and httpgrpc.
// It does the job of passing data to the cortex frontend code.
cortexTripper, v1, err := frontend.InitFrontend(t.cfg.Frontend.Config, frontend.CortexNoQuerierLimits{}, log.Logger, prometheus.DefaultRegisterer)
if err != nil {
return nil, err
}
Expand Down
87 changes: 17 additions & 70 deletions modules/frontend/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,31 @@ import (
"net/http"

"github.com/go-kit/log"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"

"github.com/grafana/tempo/modules/frontend/transport"
v1 "github.com/grafana/tempo/modules/frontend/v1"
v2 "github.com/grafana/tempo/modules/frontend/v2"
"github.com/grafana/tempo/pkg/usagestats"
"github.com/grafana/tempo/pkg/util"
)

var (
statWorkerConcurrency = usagestats.NewInt("frontend_worker_concurrency")
statVersion = usagestats.NewString("frontend_version")
statVersion = usagestats.NewString("frontend_version")
)

type Config struct {
Config CombinedFrontendConfig `yaml:",inline"`
MaxRetries int `yaml:"max_retries,omitempty"`
QueryShards int `yaml:"query_shards,omitempty"`
TolerateFailedBlocks int `yaml:"tolerate_failed_blocks,omitempty"`
Search SearchConfig `yaml:"search"`
Config v1.Config `yaml:",inline"`
MaxRetries int `yaml:"max_retries,omitempty"`
QueryShards int `yaml:"query_shards,omitempty"`
TolerateFailedBlocks int `yaml:"tolerate_failed_blocks,omitempty"`
Search SearchConfig `yaml:"search"`
}

type SearchConfig struct {
Sharder SearchSharderConfig `yaml:",inline"`
}

func (cfg *Config) RegisterFlagsAndApplyDefaults(prefix string, f *flag.FlagSet) {
cfg.Config.DownstreamURL = ""
cfg.Config.Handler.LogQueriesLongerThan = 0
cfg.Config.FrontendV1.MaxOutstandingPerTenant = 100
func (cfg *Config) RegisterFlagsAndApplyDefaults(string, *flag.FlagSet) {
cfg.Config.MaxOutstandingPerTenant = 100
cfg.MaxRetries = 2
cfg.QueryShards = 20
cfg.TolerateFailedBlocks = 0
Expand All @@ -58,66 +52,19 @@ type CortexNoQuerierLimits struct{}

var _ v1.Limits = (*CortexNoQuerierLimits)(nil)

func (CortexNoQuerierLimits) MaxQueriersPerUser(user string) int { return 0 }
func (CortexNoQuerierLimits) MaxQueriersPerUser(string) int { return 0 }

// This struct combines several configuration options together to preserve backwards compatibility.
type CombinedFrontendConfig struct {
Handler transport.HandlerConfig `yaml:",inline"`
FrontendV1 v1.Config `yaml:",inline"`
FrontendV2 v2.Config `yaml:",inline"`

DownstreamURL string `yaml:"downstream_url"`
}

func (cfg *CombinedFrontendConfig) RegisterFlags(f *flag.FlagSet) {
cfg.Handler.RegisterFlags(f)
cfg.FrontendV1.RegisterFlags(f)
cfg.FrontendV2.RegisterFlags(f)

f.StringVar(&cfg.DownstreamURL, "frontend.downstream-url", "", "URL of downstream Prometheus.")
}

// InitFrontend initializes frontend (either V1 -- without scheduler, or V2 -- with scheduler) or no frontend at
// all if downstream Prometheus URL is used instead.
// InitFrontend initializes V1 frontend
//
// Returned RoundTripper can be wrapped in more round-tripper middlewares, and then eventually registered
// into HTTP server using the Handler from this package. Returned RoundTripper is always non-nil
// (if there are no errors), and it uses the returned frontend (if any).
func InitFrontend(cfg CombinedFrontendConfig, limits v1.Limits, grpcListenPort int, log log.Logger, reg prometheus.Registerer) (http.RoundTripper, *v1.Frontend, *v2.Frontend, error) {
switch {
case cfg.DownstreamURL != "":
// If the user has specified a downstream Prometheus, then we should use that.
rt, err := NewDownstreamRoundTripper(cfg.DownstreamURL, http.DefaultTransport)
return rt, nil, nil, err

case cfg.FrontendV2.SchedulerAddress != "":
statVersion.Set("v2")
statWorkerConcurrency.Set(int64(cfg.FrontendV2.WorkerConcurrency))

// If query-scheduler address is configured, use Frontend.
if cfg.FrontendV2.Addr == "" {
addr, err := util.GetFirstAddressOf(cfg.FrontendV2.InfNames)
if err != nil {
return nil, nil, nil, errors.Wrap(err, "failed to get frontend address")
}

cfg.FrontendV2.Addr = addr
}

if cfg.FrontendV2.Port == 0 {
cfg.FrontendV2.Port = grpcListenPort
}

fr, err := v2.NewFrontend(cfg.FrontendV2, log, reg)
return transport.AdaptGrpcRoundTripperToHTTPRoundTripper(fr), nil, fr, err

default:
statVersion.Set("v1")
// No scheduler = use original frontend.
fr, err := v1.New(cfg.FrontendV1, limits, log, reg)
if err != nil {
return nil, nil, nil, err
}
return transport.AdaptGrpcRoundTripperToHTTPRoundTripper(fr), fr, nil, nil
func InitFrontend(cfg v1.Config, limits v1.Limits, log log.Logger, reg prometheus.Registerer) (http.RoundTripper, *v1.Frontend, error) {
statVersion.Set("v1")
// No scheduler = use original frontend.
fr, err := v1.New(cfg, limits, log, reg)
if err != nil {
return nil, nil, err
}
return transport.AdaptGrpcRoundTripperToHTTPRoundTripper(fr), fr, nil
}
4 changes: 2 additions & 2 deletions modules/frontend/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (

"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/golang/protobuf/jsonpb" //nolint:all //deprecated
"github.com/golang/protobuf/proto" //nolint:all //deprecated
"github.com/golang/protobuf/jsonpb" //nolint:all //deprecated
"github.com/golang/protobuf/proto" //nolint:all //deprecated
"github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
Expand Down
2 changes: 1 addition & 1 deletion modules/frontend/tracebyidsharding.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/golang/protobuf/proto" //nolint:all //deprecated
"github.com/golang/protobuf/proto" //nolint:all //deprecated
"github.com/grafana/tempo/modules/querier"
"github.com/grafana/tempo/pkg/api"
"github.com/grafana/tempo/pkg/model/trace"
Expand Down
Loading