Skip to content

Commit f6f39d6

Browse files
Tyler Reidalvinlin123
authored andcommitted
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]> Signed-off-by: Alvin Lin <[email protected]>
1 parent 497082d commit f6f39d6

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
* [FEATURE] AlertManager: Add support for SNS Receiver. #4382
1010
=======
1111

12+
* [CHANGE] Changed default for `-ingester.min-ready-duration` from 1 minute to 15 seconds. #4539
13+
* [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
14+
* [ENHANCEMENT] Added new ring related config `-distributor.excluded-zones` when set this will exclude the comma-separated zones from the ring, default is "". #4539
1215
* [ENHANCEMENT] Upgraded Docker base images to `alpine:3.14`. #4514
1316
* [ENHANCEMENT] Updated Prometheus to latest. Includes changes from prometheus#9239, adding 15 new functions. Multiple TSDB bugfixes prometheus#9438 & prometheus#9381. #4524
1417

docs/configuration/config-file-reference.md

Lines changed: 19 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 3 deletions
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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) {

0 commit comments

Comments
 (0)