Skip to content

Commit 127158b

Browse files
committed
Remove dead code
Signed-off-by: Alan Protasio <[email protected]>
1 parent cacabd4 commit 127158b

File tree

9 files changed

+25
-123
lines changed

9 files changed

+25
-123
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
- `-ingester.chunk-age-jitter`
3232
- `-ingester.concurrent-flushes`
3333
- `-ingester.spread-flushes`
34-
- `-store.*` except `-store.engine` and `-store.max-query-length`
34+
- `-store.*` except `-store.engine` and `-store.max-query-length`
3535
- `-store.query-chunk-limit` was deprecated and replaced by `-querier.max-fetched-chunks-per-query`
3636
- `-deletes.*`
3737
- `-grpc-store.*`

docs/blocks-storage/_index.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,6 @@ For more information, please refer to the following dedicated sections:
6666
- [Store-gateway](./store-gateway.md)
6767
- [Production tips](./production-tips.md)
6868

69-
## Configuration
70-
71-
The general [configuration documentation](../configuration/config-file-reference.md) also applies to a Cortex cluster running the blocks storage. The blocks storage can be enabled switching the storage `engine` to `blocks`:
72-
73-
```yaml
74-
storage:
75-
# The storage engine to use. Use "blocks" for the blocks storage.
76-
# CLI flag: -store.engine
77-
engine: blocks
78-
```
79-
8069
## Known issues
8170

8271
GitHub issues tagged with the [`storage/blocks`](https://github.com/cortexproject/cortex/issues?q=is%3Aopen+is%3Aissue+label%3Astorage%2Fblocks) label are the best source of currently known issues affecting the blocks storage.

pkg/cortex/cortex.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ import (
2525
"github.com/cortexproject/cortex/pkg/alertmanager/alertstore"
2626
"github.com/cortexproject/cortex/pkg/api"
2727
"github.com/cortexproject/cortex/pkg/chunk/purger"
28-
"github.com/cortexproject/cortex/pkg/chunk/storage"
2928
"github.com/cortexproject/cortex/pkg/compactor"
3029
"github.com/cortexproject/cortex/pkg/configs"
3130
configAPI "github.com/cortexproject/cortex/pkg/configs/api"
3231
"github.com/cortexproject/cortex/pkg/configs/db"
32+
"github.com/cortexproject/cortex/pkg/cortex/storage"
3333
"github.com/cortexproject/cortex/pkg/cortexpb"
3434
"github.com/cortexproject/cortex/pkg/distributor"
3535
"github.com/cortexproject/cortex/pkg/flusher"

pkg/cortex/cortex_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"testing"
1313
"time"
1414

15+
"github.com/cortexproject/cortex/pkg/cortex/storage"
1516
"github.com/cortexproject/cortex/pkg/ruler/rulestore"
1617
"github.com/cortexproject/cortex/pkg/ruler/rulestore/local"
1718

@@ -23,7 +24,6 @@ import (
2324
"google.golang.org/grpc"
2425
"google.golang.org/grpc/credentials/insecure"
2526

26-
"github.com/cortexproject/cortex/pkg/chunk/storage"
2727
"github.com/cortexproject/cortex/pkg/frontend/v1/frontendv1pb"
2828
"github.com/cortexproject/cortex/pkg/ingester"
2929
"github.com/cortexproject/cortex/pkg/ring"

pkg/cortex/modules.go

Lines changed: 16 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"github.com/cortexproject/cortex/pkg/alertmanager/alertstore"
2222
"github.com/cortexproject/cortex/pkg/api"
2323
"github.com/cortexproject/cortex/pkg/chunk/purger"
24-
"github.com/cortexproject/cortex/pkg/chunk/storage"
2524
"github.com/cortexproject/cortex/pkg/compactor"
2625
configAPI "github.com/cortexproject/cortex/pkg/configs/api"
2726
"github.com/cortexproject/cortex/pkg/configs/db"
@@ -65,9 +64,7 @@ const (
6564
StoreQueryable string = "store-queryable"
6665
QueryFrontend string = "query-frontend"
6766
QueryFrontendTripperware string = "query-frontend-tripperware"
68-
Store string = "store"
6967
DeleteRequestsStore string = "delete-requests-store"
70-
TableManager string = "table-manager"
7168
RulerStorage string = "ruler-storage"
7269
Ruler string = "ruler"
7370
Configs string = "configs"
@@ -345,8 +342,8 @@ func (t *Cortex) initStoreQueryables() (services.Service, error) {
345342
var servs []services.Service
346343

347344
//nolint:golint // I prefer this form over removing 'else', because it allows q to have smaller scope.
348-
if q, err := initQueryableForEngine(t.Cfg.Storage.Engine, t.Cfg, t.Overrides, prometheus.DefaultRegisterer); err != nil {
349-
return nil, fmt.Errorf("failed to initialize querier for engine '%s': %v", t.Cfg.Storage.Engine, err)
345+
if q, err := initQueryableForEngine(t.Cfg, t.Overrides, prometheus.DefaultRegisterer); err != nil {
346+
return nil, fmt.Errorf("failed to initialize querier: %v", err)
350347
} else {
351348
t.StoreQueryables = append(t.StoreQueryables, querier.UseAlwaysQueryable(q))
352349
if s, ok := q.(services.Service); ok {
@@ -369,24 +366,17 @@ func (t *Cortex) initStoreQueryables() (services.Service, error) {
369366
}
370367
}
371368

372-
func initQueryableForEngine(engine string, cfg Config, limits *validation.Overrides, reg prometheus.Registerer) (prom_storage.Queryable, error) {
373-
switch engine {
374-
case storage.StorageEngineBlocks:
375-
// When running in single binary, if the blocks sharding is disabled and no custom
376-
// store-gateway address has been configured, we can set it to the running process.
377-
if cfg.isModuleEnabled(All) && !cfg.StoreGateway.ShardingEnabled && cfg.Querier.StoreGatewayAddresses == "" {
378-
cfg.Querier.StoreGatewayAddresses = fmt.Sprintf("127.0.0.1:%d", cfg.Server.GRPCListenPort)
379-
}
380-
381-
return querier.NewBlocksStoreQueryableFromConfig(cfg.Querier, cfg.StoreGateway, cfg.BlocksStorage, limits, util_log.Logger, reg)
382-
383-
default:
384-
return nil, fmt.Errorf("unknown storage engine '%s'", engine)
369+
func initQueryableForEngine(cfg Config, limits *validation.Overrides, reg prometheus.Registerer) (prom_storage.Queryable, error) {
370+
// When running in single binary, if the blocks sharding is disabled and no custom
371+
// store-gateway address has been configured, we can set it to the running process.
372+
if cfg.isModuleEnabled(All) && !cfg.StoreGateway.ShardingEnabled && cfg.Querier.StoreGatewayAddresses == "" {
373+
cfg.Querier.StoreGatewayAddresses = fmt.Sprintf("127.0.0.1:%d", cfg.Server.GRPCListenPort)
385374
}
375+
376+
return querier.NewBlocksStoreQueryableFromConfig(cfg.Querier, cfg.StoreGateway, cfg.BlocksStorage, limits, util_log.Logger, reg)
386377
}
387378

388379
func (t *Cortex) tsdbIngesterConfig() {
389-
t.Cfg.Ingester.BlocksStorageEnabled = t.Cfg.Storage.Engine == storage.StorageEngineBlocks
390380
t.Cfg.Ingester.BlocksStorageConfig = t.Cfg.BlocksStorage
391381
}
392382

@@ -430,13 +420,6 @@ func (t *Cortex) initFlusher() (serv services.Service, err error) {
430420
return t.Flusher, nil
431421
}
432422

433-
func (t *Cortex) initChunkStore() (serv services.Service, err error) {
434-
if t.Cfg.Storage.Engine == storage.StorageEngineChunks {
435-
return nil, errors.New("should not get here: ingesting into chunks storage is no longer supported")
436-
}
437-
return nil, nil
438-
}
439-
440423
func (t *Cortex) initDeleteRequestsStore() (serv services.Service, err error) {
441424
// no-op while blocks store does not support series deletion
442425
t.TombstonesLoader = purger.NewNoopTombstonesLoader()
@@ -597,13 +580,6 @@ func (t *Cortex) initCompactor() (serv services.Service, err error) {
597580
}
598581

599582
func (t *Cortex) initStoreGateway() (serv services.Service, err error) {
600-
if t.Cfg.Storage.Engine != storage.StorageEngineBlocks {
601-
if !t.Cfg.isModuleEnabled(All) {
602-
return nil, fmt.Errorf("storage engine must be set to blocks to enable the store-gateway")
603-
}
604-
return nil, nil
605-
}
606-
607583
t.Cfg.StoreGateway.ShardingRing.ListenPort = t.Cfg.Server.GRPCListenPort
608584

609585
t.StoreGateway, err = storegateway.NewStoreGateway(t.Cfg.StoreGateway, t.Cfg.BlocksStorage, t.Overrides, t.Cfg.Server.LogLevel, util_log.Logger, prometheus.DefaultRegisterer)
@@ -646,10 +622,6 @@ func (t *Cortex) initMemberlistKV() (services.Service, error) {
646622
}
647623

648624
func (t *Cortex) initTenantDeletionAPI() (services.Service, error) {
649-
if t.Cfg.Storage.Engine != storage.StorageEngineBlocks {
650-
return nil, nil
651-
}
652-
653625
// t.RulerStorage can be nil when running in single-binary mode, and rule storage is not configured.
654626
tenantDeletionAPI, err := purger.NewTenantDeletionAPI(t.Cfg.BlocksStorage, t.Overrides, util_log.Logger, prometheus.DefaultRegisterer)
655627
if err != nil {
@@ -684,7 +656,6 @@ func (t *Cortex) setupModuleManager() error {
684656
mm.RegisterModule(OverridesExporter, t.initOverridesExporter)
685657
mm.RegisterModule(Distributor, t.initDistributor)
686658
mm.RegisterModule(DistributorService, t.initDistributorService, modules.UserInvisibleModule)
687-
mm.RegisterModule(Store, t.initChunkStore, modules.UserInvisibleModule)
688659
mm.RegisterModule(DeleteRequestsStore, t.initDeleteRequestsStore, modules.UserInvisibleModule)
689660
mm.RegisterModule(Ingester, t.initIngester)
690661
mm.RegisterModule(IngesterService, t.initIngesterService, modules.UserInvisibleModule)
@@ -716,23 +687,22 @@ func (t *Cortex) setupModuleManager() error {
716687
OverridesExporter: {RuntimeConfig},
717688
Distributor: {DistributorService, API},
718689
DistributorService: {Ring, Overrides},
719-
Store: {Overrides, DeleteRequestsStore},
720-
Ingester: {IngesterService, API},
721-
IngesterService: {Overrides, Store, RuntimeConfig, MemberlistKV},
722-
Flusher: {Store, API},
723-
Queryable: {Overrides, DistributorService, Store, Ring, API, StoreQueryable, MemberlistKV},
690+
Ingester: {IngesterService, Overrides, DeleteRequestsStore, API},
691+
IngesterService: {Overrides, RuntimeConfig, MemberlistKV},
692+
Flusher: {Overrides, DeleteRequestsStore, API},
693+
Queryable: {Overrides, DistributorService, Overrides, DeleteRequestsStore, Ring, API, StoreQueryable, MemberlistKV},
724694
Querier: {TenantFederation},
725-
StoreQueryable: {Overrides, Store, MemberlistKV},
695+
StoreQueryable: {Overrides, Overrides, DeleteRequestsStore, MemberlistKV},
726696
QueryFrontendTripperware: {API, Overrides, DeleteRequestsStore},
727697
QueryFrontend: {QueryFrontendTripperware},
728698
QueryScheduler: {API, Overrides},
729-
Ruler: {DistributorService, Store, StoreQueryable, RulerStorage},
699+
Ruler: {DistributorService, Overrides, DeleteRequestsStore, StoreQueryable, RulerStorage},
730700
RulerStorage: {Overrides},
731701
Configs: {API},
732702
AlertManager: {API, MemberlistKV, Overrides},
733703
Compactor: {API, MemberlistKV, Overrides},
734704
StoreGateway: {API, Overrides, MemberlistKV},
735-
TenantDeletion: {Store, API, Overrides},
705+
TenantDeletion: {API, Overrides, DeleteRequestsStore},
736706
Purger: {TenantDeletion},
737707
TenantFederation: {Queryable},
738708
All: {QueryFrontend, Querier, Ingester, Distributor, Purger, StoreGateway, Ruler},

pkg/chunk/storage/factory.go renamed to pkg/cortex/storage/config.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,18 @@ import (
66
"github.com/pkg/errors"
77
)
88

9-
// Supported storage engines
109
const (
11-
StorageEngineChunks = "chunks"
1210
StorageEngineBlocks = "blocks"
1311
)
1412

15-
// Config chooses which storage client to use.
1613
type Config struct {
1714
Engine string `yaml:"engine"`
1815
}
1916

20-
// RegisterFlags adds the flags required to configure this flag set.
2117
func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
2218
f.StringVar(&cfg.Engine, "store.engine", "blocks", "The storage engine to use: blocks is the only supported option today.")
2319
}
2420

25-
// Validate config and returns error on failure
2621
func (cfg *Config) Validate() error {
2722
if cfg.Engine != StorageEngineBlocks {
2823
return errors.New("unsupported storage engine (only blocks is supported for ingest)")

pkg/ingester/ingester.go

Lines changed: 5 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ type Config struct {
5959
ActiveSeriesMetricsIdleTimeout time.Duration `yaml:"active_series_metrics_idle_timeout"`
6060

6161
// Use blocks storage.
62-
BlocksStorageEnabled bool `yaml:"-"`
6362
BlocksStorageConfig tsdb.BlocksStorageConfig `yaml:"-"`
6463
StreamChunksWhenUsingBlocks bool `yaml:"-"`
6564
// Runtime-override for type of streaming query to use (chunks or samples).
@@ -152,11 +151,6 @@ type Ingester struct {
152151

153152
// New constructs a new Ingester.
154153
func New(cfg Config, limits *validation.Overrides, registerer prometheus.Registerer, logger log.Logger) (*Ingester, error) {
155-
if !cfg.BlocksStorageEnabled {
156-
// TODO FIXME error message
157-
return nil, fmt.Errorf("chunks storage is no longer supported")
158-
}
159-
160154
defaultInstanceLimits = &cfg.DefaultLimits
161155

162156
if cfg.ingesterClientFactory == nil {
@@ -177,7 +171,7 @@ func NewForFlusher(cfg Config, limits *validation.Overrides, registerer promethe
177171
// ShutdownHandler triggers the following set of operations in order:
178172
// * Change the state of ring to stop accepting writes.
179173
// * Flush all the chunks.
180-
func (i *Ingester) ShutdownHandler(w http.ResponseWriter, r *http.Request) {
174+
func (i *Ingester) ShutdownHandler(w http.ResponseWriter, _ *http.Request) {
181175
originalFlush := i.lifecycler.FlushOnShutdown()
182176
// We want to flush the chunks if transfer fails irrespective of original flag.
183177
i.lifecycler.SetFlushOnShutdown(true)
@@ -364,21 +358,7 @@ func (i *Ingester) LabelValues(ctx context.Context, req *client.LabelValuesReque
364358
}
365359

366360
func (i *Ingester) LabelValuesStream(req *client.LabelValuesRequest, stream client.Ingester_LabelValuesStreamServer) error {
367-
if i.cfg.BlocksStorageEnabled {
368-
return i.v2LabelValuesStream(req, stream)
369-
}
370-
371-
resp, err := i.LabelValues(stream.Context(), req)
372-
if err != nil {
373-
return err
374-
}
375-
376-
return client.SendAsBatchToStream(len(resp.LabelValues), metadataStreamBatchSize, func(i, j int) error {
377-
resp := &client.LabelValuesStreamResponse{
378-
LabelValues: resp.LabelValues[i:j],
379-
}
380-
return client.SendLabelValuesStream(stream, resp)
381-
})
361+
return i.v2LabelValuesStream(req, stream)
382362
}
383363

384364
// LabelNames return all the label names.
@@ -388,21 +368,7 @@ func (i *Ingester) LabelNames(ctx context.Context, req *client.LabelNamesRequest
388368

389369
// LabelNames return all the label names.
390370
func (i *Ingester) LabelNamesStream(req *client.LabelNamesRequest, stream client.Ingester_LabelNamesStreamServer) error {
391-
if i.cfg.BlocksStorageEnabled {
392-
return i.v2LabelNamesStream(req, stream)
393-
}
394-
395-
resp, err := i.LabelNames(stream.Context(), req)
396-
if err != nil {
397-
return err
398-
}
399-
400-
return client.SendAsBatchToStream(len(resp.LabelNames), metadataStreamBatchSize, func(i, j int) error {
401-
resp := &client.LabelNamesStreamResponse{
402-
LabelNames: resp.LabelNames[i:j],
403-
}
404-
return client.SendLabelNamesStream(stream, resp)
405-
})
371+
return i.v2LabelNamesStream(req, stream)
406372
}
407373

408374
// MetricsForLabelMatchers returns all the metrics which match a set of matchers.
@@ -411,26 +377,11 @@ func (i *Ingester) MetricsForLabelMatchers(ctx context.Context, req *client.Metr
411377
}
412378

413379
func (i *Ingester) MetricsForLabelMatchersStream(req *client.MetricsForLabelMatchersRequest, stream client.Ingester_MetricsForLabelMatchersStreamServer) error {
414-
if i.cfg.BlocksStorageEnabled {
415-
return i.v2MetricsForLabelMatchersStream(req, stream)
416-
}
417-
418-
resp, err := i.MetricsForLabelMatchers(stream.Context(), req)
419-
420-
if err != nil {
421-
return err
422-
}
423-
424-
return client.SendAsBatchToStream(len(resp.Metric), metadataStreamBatchSize, func(i, j int) error {
425-
resp := &client.MetricsForLabelMatchersStreamResponse{
426-
Metric: resp.Metric[i:j],
427-
}
428-
return client.SendMetricsForLabelMatchersStream(stream, resp)
429-
})
380+
return i.v2MetricsForLabelMatchersStream(req, stream)
430381
}
431382

432383
// MetricsMetadata returns all the metric metadata of a user.
433-
func (i *Ingester) MetricsMetadata(ctx context.Context, req *client.MetricsMetadataRequest) (*client.MetricsMetadataResponse, error) {
384+
func (i *Ingester) MetricsMetadata(ctx context.Context, _ *client.MetricsMetadataRequest) (*client.MetricsMetadataResponse, error) {
434385
i.stoppedMtx.RLock()
435386
if err := i.checkRunningOrStopping(); err != nil {
436387
i.stoppedMtx.RUnlock()

pkg/ingester/ingester_v2_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2178,7 +2178,6 @@ func prepareIngesterWithBlocksStorageAndLimits(t testing.TB, ingesterCfg Config,
21782178
return nil, err
21792179
}
21802180

2181-
ingesterCfg.BlocksStorageEnabled = true
21822181
ingesterCfg.BlocksStorageConfig.TSDB.Dir = dataDir
21832182
ingesterCfg.BlocksStorageConfig.Bucket.Backend = "filesystem"
21842183
ingesterCfg.BlocksStorageConfig.Bucket.Filesystem.Directory = bucketDir
@@ -2316,7 +2315,6 @@ func TestIngester_v2OpenExistingTSDBOnStartup(t *testing.T) {
23162315
tempDir := t.TempDir()
23172316

23182317
ingesterCfg := defaultIngesterTestConfig(t)
2319-
ingesterCfg.BlocksStorageEnabled = true
23202318
ingesterCfg.BlocksStorageConfig.TSDB.Dir = tempDir
23212319
ingesterCfg.BlocksStorageConfig.TSDB.MaxTSDBOpeningConcurrencyOnStartup = testData.concurrency
23222320
ingesterCfg.BlocksStorageConfig.Bucket.Backend = "s3"
@@ -3361,7 +3359,6 @@ func TestHeadCompactionOnStartup(t *testing.T) {
33613359
require.NoError(t, err)
33623360

33633361
ingesterCfg := defaultIngesterTestConfig(t)
3364-
ingesterCfg.BlocksStorageEnabled = true
33653362
ingesterCfg.BlocksStorageConfig.TSDB.Dir = tempDir
33663363
ingesterCfg.BlocksStorageConfig.Bucket.Backend = "s3"
33673364
ingesterCfg.BlocksStorageConfig.Bucket.S3.Endpoint = "localhost"

tools/doc-generator/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import (
1414
"github.com/cortexproject/cortex/pkg/alertmanager"
1515
"github.com/cortexproject/cortex/pkg/alertmanager/alertstore"
1616
"github.com/cortexproject/cortex/pkg/chunk/cache"
17-
"github.com/cortexproject/cortex/pkg/chunk/storage"
1817
"github.com/cortexproject/cortex/pkg/compactor"
1918
"github.com/cortexproject/cortex/pkg/configs"
2019
config_client "github.com/cortexproject/cortex/pkg/configs/client"
2120
"github.com/cortexproject/cortex/pkg/cortex"
21+
"github.com/cortexproject/cortex/pkg/cortex/storage"
2222
"github.com/cortexproject/cortex/pkg/distributor"
2323
"github.com/cortexproject/cortex/pkg/flusher"
2424
"github.com/cortexproject/cortex/pkg/frontend"

0 commit comments

Comments
 (0)