Skip to content

Commit f2656f8

Browse files
author
Tyler Reid
authored
Migrate to dskit/ring (cortexproject#4539)
* Migrate to dskit/ring Signed-off-by: Tyler Reid <[email protected]> * Tidy those mods Signed-off-by: Tyler Reid <[email protected]> * Update docs on my branch Signed-off-by: Tyler Reid <[email protected]> * Wrap multi-tenant alert manager lifecycler registerer with cortex prefix Signed-off-by: Tyler Reid <[email protected]> * Add changelog for new configs brought in via dskit Signed-off-by: Tyler Reid <[email protected]> * Remove whitespace in changelog Signed-off-by: Tyler Reid <[email protected]>
1 parent a71dff8 commit f2656f8

File tree

89 files changed

+725
-6139
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+725
-6139
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## master / unreleased
44

5+
* [CHANGE] Changed default for `-ingester.min-ready-duration` from 1 minute to 15 seconds. #4539
6+
* [ENHANCEMENT] Added new ring related config `-ingester.readiness-check-ring-health` when enabled the readiness probe will succeed only after all instances are ACTIVE and healthy in the ring, this is enabled by default. #4539
7+
* [ENHANCEMENT] Added new ring related config `-distributor.excluded-zones` when set this will exclude the comma-separated zones from the ring, default is "". #4539
58
* [ENHANCEMENT] Upgraded Docker base images to `alpine:3.14`. #4514
69
* [ENHANCEMENT] Updated Prometheus to latest. Includes changes from prometheus#9239, adding 15 new functions. Multiple TSDB bugfixes prometheus#9438 & prometheus#9381. #4524
710

docs/configuration/config-file-reference.md

+19-3
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,11 @@ lifecycler:
683683
# CLI flag: -distributor.zone-awareness-enabled
684684
[zone_awareness_enabled: <boolean> | default = false]
685685
686+
# Comma-separated list of zones to exclude from the ring. Instances in
687+
# excluded zones will be filtered out from the ring.
688+
# CLI flag: -distributor.excluded-zones
689+
[excluded_zones: <string> | default = ""]
690+
686691
# Number of tokens for each ingester.
687692
# CLI flag: -ingester.num-tokens
688693
[num_tokens: <int> | default = 128]
@@ -701,10 +706,13 @@ lifecycler:
701706
# CLI flag: -ingester.join-after
702707
[join_after: <duration> | default = 0s]
703708
704-
# Minimum duration to wait before becoming ready. This is to work around race
705-
# conditions with ingesters exiting and updating the ring.
709+
# Minimum duration to wait after the internal readiness checks have passed but
710+
# before succeeding the readiness endpoint. This is used to slowdown
711+
# deployment controllers (eg. Kubernetes) after an instance is ready and
712+
# before they proceed with a rolling update, to give the rest of the cluster
713+
# instances enough time to receive ring updates.
706714
# CLI flag: -ingester.min-ready-duration
707-
[min_ready_duration: <duration> | default = 1m]
715+
[min_ready_duration: <duration> | default = 15s]
708716
709717
# Name of network interface to read address from.
710718
# CLI flag: -ingester.lifecycler.interface
@@ -729,6 +737,14 @@ lifecycler:
729737
# CLI flag: -ingester.unregister-on-shutdown
730738
[unregister_on_shutdown: <boolean> | default = true]
731739
740+
# When enabled the readiness probe succeeds only after all instances are
741+
# ACTIVE and healthy in the ring, otherwise only the instance itself is
742+
# checked. This option should be disabled if in your cluster multiple
743+
# instances can be rolled out simultaneously, otherwise rolling updates may be
744+
# slowed down.
745+
# CLI flag: -ingester.readiness-check-ring-health
746+
[readiness_check_ring_health: <boolean> | default = true]
747+
732748
# Number of times to try and transfer chunks before falling back to flushing.
733749
# Negative value or zero disables hand-over. This feature is supported only by
734750
# the chunks storage.

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ require (
2929
github.com/golang/protobuf v1.5.2
3030
github.com/golang/snappy v0.0.4
3131
github.com/gorilla/mux v1.8.0
32-
github.com/grafana/dskit v0.0.0-20211011144203-3a88ec0b675f
32+
github.com/grafana/dskit v0.0.0-20211021180445-3bd016e9d7f1
3333
github.com/json-iterator/go v1.1.11
3434
github.com/lib/pq v1.3.0
3535
github.com/minio/minio-go/v7 v7.0.10

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -1012,8 +1012,8 @@ github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoA
10121012
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
10131013
github.com/grafana/dskit v0.0.0-20210818123532-6645f87e9e12/go.mod h1:QaNAQaCSFOtG/NHf6Jd/zh67H25kkrVCq36U61Y2Mhw=
10141014
github.com/grafana/dskit v0.0.0-20210819132858-471020752967/go.mod h1:uF46UNN1/feB1egpq8UGbBBKvJjGgZauW7pcVbeFLLM=
1015-
github.com/grafana/dskit v0.0.0-20211011144203-3a88ec0b675f h1:FvvSVEbnGeM2bUivGmsiXTi8URJyBU7TcFEEoRe5wWI=
1016-
github.com/grafana/dskit v0.0.0-20211011144203-3a88ec0b675f/go.mod h1:uPG2nyK4CtgNDmWv7qyzYcdI+S90kHHRWvHnBtEMBXM=
1015+
github.com/grafana/dskit v0.0.0-20211021180445-3bd016e9d7f1 h1:Qf+/W3Tup0nO21tgJmO14WJK0yyrm4L2UJipZP+Zoow=
1016+
github.com/grafana/dskit v0.0.0-20211021180445-3bd016e9d7f1/go.mod h1:uPG2nyK4CtgNDmWv7qyzYcdI+S90kHHRWvHnBtEMBXM=
10171017
github.com/grafana/gocql v0.0.0-20200605141915-ba5dc39ece85 h1:xLuzPoOzdfNb/RF/IENCw+oLVdZB4G21VPhkHBgwSHY=
10181018
github.com/grafana/gocql v0.0.0-20200605141915-ba5dc39ece85/go.mod h1:crI9WX6p0IhrqB+DqIUHulRW853PaNFf7o4UprV//3I=
10191019
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=

pkg/alertmanager/alertmanager_client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import (
77
"github.com/go-kit/log"
88
"github.com/grafana/dskit/crypto/tls"
99
"github.com/grafana/dskit/grpcclient"
10+
"github.com/grafana/dskit/ring/client"
1011
"github.com/pkg/errors"
1112
"github.com/prometheus/client_golang/prometheus"
1213
"github.com/prometheus/client_golang/prometheus/promauto"
1314
"google.golang.org/grpc"
1415
"google.golang.org/grpc/health/grpc_health_v1"
1516

1617
"github.com/cortexproject/cortex/pkg/alertmanager/alertmanagerpb"
17-
"github.com/cortexproject/cortex/pkg/ring/client"
1818
)
1919

2020
// ClientsPool is the interface used to get the client from the pool for a specified address.

pkg/alertmanager/alertmanager_ring.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import (
66
"os"
77
"time"
88

9+
"github.com/go-kit/log"
910
"github.com/go-kit/log/level"
1011
"github.com/grafana/dskit/flagext"
1112
"github.com/grafana/dskit/kv"
13+
"github.com/grafana/dskit/ring"
1214

13-
"github.com/cortexproject/cortex/pkg/ring"
1415
util_log "github.com/cortexproject/cortex/pkg/util/log"
1516
)
1617

@@ -94,8 +95,8 @@ func (cfg *RingConfig) RegisterFlags(f *flag.FlagSet) {
9495

9596
// ToLifecyclerConfig returns a LifecyclerConfig based on the alertmanager
9697
// ring config.
97-
func (cfg *RingConfig) ToLifecyclerConfig() (ring.BasicLifecyclerConfig, error) {
98-
instanceAddr, err := ring.GetInstanceAddr(cfg.InstanceAddr, cfg.InstanceInterfaceNames)
98+
func (cfg *RingConfig) ToLifecyclerConfig(logger log.Logger) (ring.BasicLifecyclerConfig, error) {
99+
instanceAddr, err := ring.GetInstanceAddr(cfg.InstanceAddr, cfg.InstanceInterfaceNames, logger)
99100
if err != nil {
100101
return ring.BasicLifecyclerConfig{}, err
101102
}

pkg/alertmanager/alertmanager_ring_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import (
44
"testing"
55
"time"
66

7+
"github.com/grafana/dskit/ring"
78
"github.com/stretchr/testify/assert"
8-
9-
"github.com/cortexproject/cortex/pkg/ring"
109
)
1110

1211
func TestIsHealthyForAlertmanagerOperations(t *testing.T) {

pkg/alertmanager/distributor.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212

1313
"github.com/go-kit/log"
1414
"github.com/go-kit/log/level"
15+
"github.com/grafana/dskit/ring"
16+
"github.com/grafana/dskit/ring/client"
1517
"github.com/grafana/dskit/services"
1618
"github.com/opentracing/opentracing-go"
1719
"github.com/pkg/errors"
@@ -20,8 +22,6 @@ import (
2022
"github.com/weaveworks/common/user"
2123

2224
"github.com/cortexproject/cortex/pkg/alertmanager/merger"
23-
"github.com/cortexproject/cortex/pkg/ring"
24-
"github.com/cortexproject/cortex/pkg/ring/client"
2525
"github.com/cortexproject/cortex/pkg/tenant"
2626
"github.com/cortexproject/cortex/pkg/util"
2727
util_log "github.com/cortexproject/cortex/pkg/util/log"

pkg/alertmanager/distributor_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/grafana/dskit/flagext"
1818
"github.com/grafana/dskit/kv"
1919
"github.com/grafana/dskit/kv/consul"
20+
"github.com/grafana/dskit/ring"
2021
"github.com/grafana/dskit/services"
2122
"github.com/prometheus/client_golang/prometheus"
2223
"github.com/stretchr/testify/assert"
@@ -27,7 +28,6 @@ import (
2728
"google.golang.org/grpc/health/grpc_health_v1"
2829

2930
"github.com/cortexproject/cortex/pkg/alertmanager/alertmanagerpb"
30-
"github.com/cortexproject/cortex/pkg/ring"
3131
util_log "github.com/cortexproject/cortex/pkg/util/log"
3232
"github.com/cortexproject/cortex/pkg/util/test"
3333
)
@@ -355,7 +355,7 @@ func prepare(t *testing.T, numAM, numHappyAM, replicationFactor int, responseBod
355355
},
356356
HeartbeatTimeout: 60 * time.Minute,
357357
ReplicationFactor: replicationFactor,
358-
}, RingNameForServer, RingKey, nil)
358+
}, RingNameForServer, RingKey, nil, nil)
359359
require.NoError(t, err)
360360
require.NoError(t, services.StartAndAwaitRunning(context.Background(), amRing))
361361
test.Poll(t, time.Second, numAM, func() interface{} {

pkg/alertmanager/lifecycle.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package alertmanager
22

33
import (
4-
"github.com/cortexproject/cortex/pkg/ring"
4+
"github.com/grafana/dskit/ring"
55
)
66

77
func (r *MultitenantAlertmanager) OnRingInstanceRegister(_ *ring.BasicLifecycler, ringDesc ring.Desc, instanceExists bool, instanceID string, instanceDesc ring.InstanceDesc) (ring.InstanceState, ring.Tokens) {

pkg/alertmanager/multitenant.go

+5-9
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import (
1818
"github.com/grafana/dskit/concurrency"
1919
"github.com/grafana/dskit/flagext"
2020
"github.com/grafana/dskit/kv"
21+
"github.com/grafana/dskit/ring"
22+
"github.com/grafana/dskit/ring/client"
2123
"github.com/grafana/dskit/services"
2224
"github.com/pkg/errors"
2325
"github.com/prometheus/alertmanager/cluster"
@@ -34,8 +36,6 @@ import (
3436
"github.com/cortexproject/cortex/pkg/alertmanager/alertmanagerpb"
3537
"github.com/cortexproject/cortex/pkg/alertmanager/alertspb"
3638
"github.com/cortexproject/cortex/pkg/alertmanager/alertstore"
37-
"github.com/cortexproject/cortex/pkg/ring"
38-
"github.com/cortexproject/cortex/pkg/ring/client"
3939
"github.com/cortexproject/cortex/pkg/tenant"
4040
"github.com/cortexproject/cortex/pkg/util"
4141
util_log "github.com/cortexproject/cortex/pkg/util/log"
@@ -398,7 +398,7 @@ func createMultitenantAlertmanager(cfg *MultitenantAlertmanagerConfig, fallbackC
398398
}
399399

400400
if cfg.ShardingEnabled {
401-
lifecyclerCfg, err := am.cfg.ShardingRing.ToLifecyclerConfig()
401+
lifecyclerCfg, err := am.cfg.ShardingRing.ToLifecyclerConfig(am.logger)
402402
if err != nil {
403403
return nil, errors.Wrap(err, "failed to initialize Alertmanager's lifecycler config")
404404
}
@@ -409,20 +409,16 @@ func createMultitenantAlertmanager(cfg *MultitenantAlertmanagerConfig, fallbackC
409409
delegate = ring.NewLeaveOnStoppingDelegate(delegate, am.logger)
410410
delegate = ring.NewAutoForgetDelegate(am.cfg.ShardingRing.HeartbeatTimeout*ringAutoForgetUnhealthyPeriods, delegate, am.logger)
411411

412-
am.ringLifecycler, err = ring.NewBasicLifecycler(lifecyclerCfg, RingNameForServer, RingKey, ringStore, delegate, am.logger, am.registry)
412+
am.ringLifecycler, err = ring.NewBasicLifecycler(lifecyclerCfg, RingNameForServer, RingKey, ringStore, delegate, am.logger, prometheus.WrapRegistererWithPrefix("cortex_", am.registry))
413413
if err != nil {
414414
return nil, errors.Wrap(err, "failed to initialize Alertmanager's lifecycler")
415415
}
416416

417-
am.ring, err = ring.NewWithStoreClientAndStrategy(am.cfg.ShardingRing.ToRingConfig(), RingNameForServer, RingKey, ringStore, ring.NewIgnoreUnhealthyInstancesReplicationStrategy())
417+
am.ring, err = ring.NewWithStoreClientAndStrategy(am.cfg.ShardingRing.ToRingConfig(), RingNameForServer, RingKey, ringStore, ring.NewIgnoreUnhealthyInstancesReplicationStrategy(), prometheus.WrapRegistererWithPrefix("cortex_", am.registry), am.logger)
418418
if err != nil {
419419
return nil, errors.Wrap(err, "failed to initialize Alertmanager's ring")
420420
}
421421

422-
if am.registry != nil {
423-
am.registry.MustRegister(am.ring)
424-
}
425-
426422
am.grpcServer = server.NewServer(&handlerForGRPCServer{am: am})
427423

428424
am.alertmanagerClientsPool = newAlertmanagerClientsPool(client.NewRingServiceDiscovery(am.ring), cfg.AlertmanagerClient, logger, am.registry)

pkg/alertmanager/multitenant_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/grafana/dskit/concurrency"
2424
"github.com/grafana/dskit/flagext"
2525
"github.com/grafana/dskit/kv/consul"
26+
"github.com/grafana/dskit/ring"
2627
"github.com/grafana/dskit/services"
2728
"github.com/prometheus/alertmanager/cluster/clusterpb"
2829
"github.com/prometheus/alertmanager/notify"
@@ -44,7 +45,6 @@ import (
4445
"github.com/cortexproject/cortex/pkg/alertmanager/alertspb"
4546
"github.com/cortexproject/cortex/pkg/alertmanager/alertstore"
4647
"github.com/cortexproject/cortex/pkg/alertmanager/alertstore/bucketclient"
47-
"github.com/cortexproject/cortex/pkg/ring"
4848
"github.com/cortexproject/cortex/pkg/storage/bucket"
4949
"github.com/cortexproject/cortex/pkg/util"
5050
"github.com/cortexproject/cortex/pkg/util/test"
@@ -1445,7 +1445,7 @@ func TestAlertmanager_ReplicasPosition(t *testing.T) {
14451445

14461446
// First, create the alertmanager instances, we'll use a replication factor of 3 and create 3 instances so that we can get the tenant on each replica.
14471447
for i := 1; i <= 3; i++ {
1448-
//instanceIDs = append(instanceIDs, fmt.Sprintf("alertmanager-%d", i))
1448+
// instanceIDs = append(instanceIDs, fmt.Sprintf("alertmanager-%d", i))
14491449
instanceID := fmt.Sprintf("alertmanager-%d", i)
14501450

14511451
amConfig := mockAlertmanagerConfig(t)

pkg/api/api.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/felixge/fgprof"
1313
"github.com/go-kit/log"
1414
"github.com/go-kit/log/level"
15+
"github.com/grafana/dskit/ring"
1516
"github.com/prometheus/client_golang/prometheus"
1617
"github.com/prometheus/prometheus/storage"
1718
"github.com/weaveworks/common/middleware"
@@ -30,7 +31,6 @@ import (
3031
"github.com/cortexproject/cortex/pkg/frontend/v2/frontendv2pb"
3132
"github.com/cortexproject/cortex/pkg/ingester/client"
3233
"github.com/cortexproject/cortex/pkg/querier"
33-
"github.com/cortexproject/cortex/pkg/ring"
3434
"github.com/cortexproject/cortex/pkg/ruler"
3535
"github.com/cortexproject/cortex/pkg/scheduler"
3636
"github.com/cortexproject/cortex/pkg/scheduler/schedulerpb"

pkg/compactor/compactor.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/go-kit/log/level"
1818
"github.com/grafana/dskit/backoff"
1919
"github.com/grafana/dskit/flagext"
20+
"github.com/grafana/dskit/ring"
2021
"github.com/grafana/dskit/services"
2122
"github.com/pkg/errors"
2223
"github.com/prometheus/client_golang/prometheus"
@@ -28,7 +29,6 @@ import (
2829
"github.com/thanos-io/thanos/pkg/compact/downsample"
2930
"github.com/thanos-io/thanos/pkg/objstore"
3031

31-
"github.com/cortexproject/cortex/pkg/ring"
3232
"github.com/cortexproject/cortex/pkg/storage/bucket"
3333
cortex_tsdb "github.com/cortexproject/cortex/pkg/storage/tsdb"
3434
"github.com/cortexproject/cortex/pkg/storage/tsdb/bucketindex"
@@ -367,12 +367,12 @@ func (c *Compactor) starting(ctx context.Context) error {
367367
// Initialize the compactors ring if sharding is enabled.
368368
if c.compactorCfg.ShardingEnabled {
369369
lifecyclerCfg := c.compactorCfg.ShardingRing.ToLifecyclerConfig()
370-
c.ringLifecycler, err = ring.NewLifecycler(lifecyclerCfg, ring.NewNoopFlushTransferer(), "compactor", ring.CompactorRingKey, false, c.registerer)
370+
c.ringLifecycler, err = ring.NewLifecycler(lifecyclerCfg, ring.NewNoopFlushTransferer(), "compactor", ring.CompactorRingKey, false, c.logger, prometheus.WrapRegistererWithPrefix("cortex_", c.registerer))
371371
if err != nil {
372372
return errors.Wrap(err, "unable to initialize compactor ring lifecycler")
373373
}
374374

375-
c.ring, err = ring.New(lifecyclerCfg.RingConfig, "compactor", ring.CompactorRingKey, c.registerer)
375+
c.ring, err = ring.New(lifecyclerCfg.RingConfig, "compactor", ring.CompactorRingKey, c.logger, prometheus.WrapRegistererWithPrefix("cortex_", c.registerer))
376376
if err != nil {
377377
return errors.Wrap(err, "unable to initialize compactor ring")
378378
}

pkg/compactor/compactor_ring.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"github.com/go-kit/log/level"
99
"github.com/grafana/dskit/flagext"
1010
"github.com/grafana/dskit/kv"
11+
"github.com/grafana/dskit/ring"
1112

12-
"github.com/cortexproject/cortex/pkg/ring"
1313
util_log "github.com/cortexproject/cortex/pkg/util/log"
1414
)
1515

pkg/compactor/compactor_ring_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import (
55
"time"
66

77
"github.com/grafana/dskit/flagext"
8+
"github.com/grafana/dskit/ring"
89
"github.com/stretchr/testify/assert"
9-
10-
"github.com/cortexproject/cortex/pkg/ring"
1110
)
1211

1312
func TestRingConfig_DefaultConfigToLifecyclerConfig(t *testing.T) {

pkg/compactor/compactor_test.go

+22-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ import (
3636
"github.com/thanos-io/thanos/pkg/objstore"
3737
"gopkg.in/yaml.v2"
3838

39-
"github.com/cortexproject/cortex/pkg/ring"
39+
"github.com/grafana/dskit/ring"
40+
4041
"github.com/cortexproject/cortex/pkg/storage/bucket"
4142
cortex_tsdb "github.com/cortexproject/cortex/pkg/storage/tsdb"
4243
cortex_testutil "github.com/cortexproject/cortex/pkg/util/test"
@@ -1060,6 +1061,22 @@ func findCompactorByUserID(compactors []*Compactor, logs []*concurrency.SyncBuff
10601061
}
10611062

10621063
func removeIgnoredLogs(input []string) []string {
1064+
ignoredLogStringsMap := map[string]struct{}{
1065+
// Since we moved to the component logger from the global logger for the ring in dskit these lines are now expected but are just ring setup information.
1066+
`level=info component=compactor msg="ring doesn't exist in KV store yet"`: {},
1067+
`level=info component=compactor msg="not loading tokens from file, tokens file path is empty"`: {},
1068+
`level=info component=compactor msg="instance not found in ring, adding with no tokens" ring=compactor`: {},
1069+
`level=debug component=compactor msg="JoinAfter expired" ring=compactor`: {},
1070+
`level=info component=compactor msg="auto-joining cluster after timeout" ring=compactor`: {},
1071+
`level=info component=compactor msg="lifecycler loop() exited gracefully" ring=compactor`: {},
1072+
`level=info component=compactor msg="changing instance state from" old_state=ACTIVE new_state=LEAVING ring=compactor`: {},
1073+
`level=error component=compactor msg="failed to set state to LEAVING" ring=compactor err="Changing instance state from LEAVING -> LEAVING is disallowed"`: {},
1074+
`level=error component=compactor msg="failed to set state to LEAVING" ring=compactor err="Changing instance state from JOINING -> LEAVING is disallowed"`: {},
1075+
`level=debug component=compactor msg="unregistering instance from ring" ring=compactor`: {},
1076+
`level=info component=compactor msg="instance removed from the KV store" ring=compactor`: {},
1077+
`level=info component=compactor msg="observing tokens before going ACTIVE" ring=compactor`: {},
1078+
}
1079+
10631080
out := make([]string, 0, len(input))
10641081
durationRe := regexp.MustCompile(`\s?duration=\S+`)
10651082

@@ -1069,6 +1086,10 @@ func removeIgnoredLogs(input []string) []string {
10691086
continue
10701087
}
10711088

1089+
if _, exists := ignoredLogStringsMap[log]; exists {
1090+
continue
1091+
}
1092+
10721093
// Remove any duration from logs.
10731094
log = durationRe.ReplaceAllString(log, "")
10741095

pkg/cortex/cortex.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/grafana/dskit/grpcutil"
1717
"github.com/grafana/dskit/kv/memberlist"
1818
"github.com/grafana/dskit/modules"
19+
"github.com/grafana/dskit/ring"
1920
"github.com/grafana/dskit/runtimeconfig"
2021
"github.com/grafana/dskit/services"
2122
"github.com/pkg/errors"
@@ -50,7 +51,6 @@ import (
5051
"github.com/cortexproject/cortex/pkg/querier/queryrange"
5152
"github.com/cortexproject/cortex/pkg/querier/tenantfederation"
5253
querier_worker "github.com/cortexproject/cortex/pkg/querier/worker"
53-
"github.com/cortexproject/cortex/pkg/ring"
5454
"github.com/cortexproject/cortex/pkg/ruler"
5555
"github.com/cortexproject/cortex/pkg/ruler/rulestore"
5656
"github.com/cortexproject/cortex/pkg/scheduler"

pkg/cortex/cortex_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414

1515
"github.com/grafana/dskit/flagext"
1616
"github.com/grafana/dskit/kv"
17+
"github.com/grafana/dskit/ring"
1718
"github.com/grafana/dskit/services"
1819
"github.com/prometheus/client_golang/prometheus"
1920
"github.com/stretchr/testify/assert"
@@ -26,7 +27,6 @@ import (
2627
"github.com/cortexproject/cortex/pkg/chunk/storage"
2728
"github.com/cortexproject/cortex/pkg/frontend/v1/frontendv1pb"
2829
"github.com/cortexproject/cortex/pkg/ingester"
29-
"github.com/cortexproject/cortex/pkg/ring"
3030
"github.com/cortexproject/cortex/pkg/ruler"
3131
"github.com/cortexproject/cortex/pkg/scheduler/schedulerpb"
3232
"github.com/cortexproject/cortex/pkg/storage/bucket"

0 commit comments

Comments
 (0)