Skip to content

Commit

Permalink
fix: All lifecycler cfgs ref a valid IPv6 addr and port combination (g…
Browse files Browse the repository at this point in the history
…rafana#11121)

**What this PR does / why we need it**:
Ensure that all constructors of LifeCyclerConfig are using
`net.JoinHostPort` for instance addr and port combinations. This enables
IPv6 usage compatible across the code based. Currently only distributors
provide IPv6 compatibility because they use `Lifecycler` (that pulls the
addr/port in the `NewLifeCycler`) while everything else uses
`BasicLifeCycler` delegate this to the user defining an addr/port
combination in `LifecyclerConfig`.
  • Loading branch information
periklis authored and rhnasc committed Apr 12, 2024
1 parent de3716c commit 65ab76e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -44,6 +44,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

Expand Down
5 changes: 3 additions & 2 deletions pkg/distributor/distributor_ring.go
Expand Up @@ -2,8 +2,9 @@ package distributor

import (
"flag"
"fmt"
"net"
"os"
"strconv"
"time"

"github.com/go-kit/log"
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion pkg/ruler/base/ruler_ring.go
Expand Up @@ -3,7 +3,9 @@ package base
import (
"flag"
"fmt"
"net"
"os"
"strconv"
"time"

"github.com/go-kit/log"
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions pkg/util/ring/ring_config.go
Expand Up @@ -2,8 +2,9 @@ package ring

import (
"flag"
"fmt"
"net"
"os"
"strconv"
"time"

"github.com/go-kit/log"
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 65ab76e

Please sign in to comment.