From 956fbaacbd6db71f84b5ea6a38dbaa8b42aa8754 Mon Sep 17 00:00:00 2001 From: Periklis Tsirakidis Date: Thu, 2 Nov 2023 14:47:42 +0100 Subject: [PATCH 1/2] fix: All lifecycler cfgs ref a valid IPv6 addr and port combination --- pkg/distributor/distributor_ring.go | 5 +++-- pkg/ruler/base/ruler_ring.go | 4 +++- pkg/util/ring/ring_config.go | 5 +++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/distributor/distributor_ring.go b/pkg/distributor/distributor_ring.go index fa0b04b237f8..0c7451ebdea2 100644 --- a/pkg/distributor/distributor_ring.go +++ b/pkg/distributor/distributor_ring.go @@ -2,8 +2,9 @@ package distributor import ( "flag" - "fmt" + "net" "os" + "strconv" "time" "github.com/go-kit/log" @@ -72,7 +73,7 @@ func (cfg *RingConfig) ToBasicLifecyclerConfig(logger log.Logger) (ring.BasicLif return ring.BasicLifecyclerConfig{ ID: cfg.InstanceID, - Addr: fmt.Sprintf("%s:%d", instanceAddr, instancePort), + Addr: net.JoinHostPort(instanceAddr, strconv.Itoa(instancePort)), HeartbeatPeriod: cfg.HeartbeatPeriod, HeartbeatTimeout: cfg.HeartbeatTimeout, TokensObservePeriod: 0, diff --git a/pkg/ruler/base/ruler_ring.go b/pkg/ruler/base/ruler_ring.go index ec1f19f6cfe1..697b1d8b9ac5 100644 --- a/pkg/ruler/base/ruler_ring.go +++ b/pkg/ruler/base/ruler_ring.go @@ -3,7 +3,9 @@ package base import ( "flag" "fmt" + "net" "os" + "strconv" "time" "github.com/go-kit/log" @@ -88,7 +90,7 @@ func (cfg *RingConfig) ToLifecyclerConfig(logger log.Logger) (ring.BasicLifecycl return ring.BasicLifecyclerConfig{ ID: cfg.InstanceID, - Addr: fmt.Sprintf("%s:%d", instanceAddr, instancePort), + Addr: net.JoinHostPort(instanceAddr, strconv.Itoa(instancePort)), HeartbeatPeriod: cfg.HeartbeatPeriod, TokensObservePeriod: 0, NumTokens: cfg.NumTokens, diff --git a/pkg/util/ring/ring_config.go b/pkg/util/ring/ring_config.go index 962c48d940bb..eb9945ffcb3e 100644 --- a/pkg/util/ring/ring_config.go +++ b/pkg/util/ring/ring_config.go @@ -2,8 +2,9 @@ package ring import ( "flag" - "fmt" + "net" "os" + "strconv" "time" "github.com/go-kit/log" @@ -81,7 +82,7 @@ func (cfg *RingConfig) ToLifecyclerConfig(numTokens int, logger log.Logger) (rin return ring.BasicLifecyclerConfig{ ID: cfg.InstanceID, - Addr: fmt.Sprintf("%s:%d", instanceAddr, instancePort), + Addr: net.JoinHostPort(instanceAddr, strconv.Itoa(instancePort)), Zone: cfg.InstanceZone, HeartbeatPeriod: cfg.HeartbeatPeriod, TokensObservePeriod: 0, From 9362d961e47c3045baa012441e34f73594a26f57 Mon Sep 17 00:00:00 2001 From: Periklis Tsirakidis Date: Thu, 2 Nov 2023 15:17:57 +0100 Subject: [PATCH 2/2] Add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f406c13dfbb4..c45ea3b07fbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ * [10451](https://github.com/grafana/loki/pull/10451) **shantanualsi** Upgrade thanos `objstore` * [10814](https://github.com/grafana/loki/pull/10814) **shantanualsi,kaviraj** Upgrade prometheus to v0.47.1 and dskit * [10959](https://github.com/grafana/loki/pull/10959) **slim-bean** introduce a backoff wait on subquery retries. +* [11121](https://github.com/grafana/loki/pull/11121) **periklis** Ensure all lifecycler cfgs ref a valid IPv6 addr and port combination #### Promtail