Skip to content

Commit

Permalink
chore(ui): reduce rejoin, update helm
Browse files Browse the repository at this point in the history
  • Loading branch information
cyriltovena committed Feb 25, 2025
1 parent 6651cd9 commit aa0b1f2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
6 changes: 5 additions & 1 deletion docs/sources/shared/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ ui:

# How frequently to rejoin the cluster to address split brain issues.
# CLI flag: -ui.rejoin-interval
[rejoin_interval: <duration> | default = 1m]
[rejoin_interval: <duration> | default = 3m]

# Number of initial peers to join from the discovered set.
# CLI flag: -ui.cluster-max-join-peers
Expand All @@ -138,6 +138,10 @@ ui:
# CLI flag: -ui.enable-ipv6
[enable_ipv6: <boolean> | default = false]

# Enable debug logging for the UI.
# CLI flag: -ui.debug
[debug: <boolean> | default = false]

discovery:
# List of peers to join the cluster. Supports multiple values separated by
# commas. Each value can be a hostname, an IP address, or a DNS name (A/AAAA
Expand Down
4 changes: 3 additions & 1 deletion pkg/ui/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Config struct {
ClusterMaxJoinPeers int `yaml:"cluster_max_join_peers"` // Number of initial peers to join from the discovered set.
ClusterName string `yaml:"cluster_name"` // Name to prevent nodes without this identifier from joining the cluster.
EnableIPv6 bool `yaml:"enable_ipv6"`
Debug bool `yaml:"debug"`
Discovery struct {
JoinPeers []string `yaml:"join_peers"`
} `yaml:"discovery"`
Expand All @@ -42,11 +43,12 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
f.Var((*flagext.StringSlice)(&cfg.InfNames), "ui.interface", "Name of network interface to read address from.")
f.StringVar(&cfg.NodeName, "ui.node-name", hostname, "Name to use for this node in the cluster.")
f.StringVar(&cfg.AdvertiseAddr, "ui.advertise-addr", "", "IP address to advertise in the cluster.")
f.DurationVar(&cfg.RejoinInterval, "ui.rejoin-interval", 1*time.Minute, "How frequently to rejoin the cluster to address split brain issues.")
f.DurationVar(&cfg.RejoinInterval, "ui.rejoin-interval", 3*time.Minute, "How frequently to rejoin the cluster to address split brain issues.")
f.IntVar(&cfg.ClusterMaxJoinPeers, "ui.cluster-max-join-peers", 3, "Number of initial peers to join from the discovered set.")
f.StringVar(&cfg.ClusterName, "ui.cluster-name", "", "Name to prevent nodes without this identifier from joining the cluster.")
f.BoolVar(&cfg.EnableIPv6, "ui.enable-ipv6", false, "Enable using a IPv6 instance address.")
f.Var((*flagext.StringSlice)(&cfg.Discovery.JoinPeers), "ui.discovery.join-peers", "List of peers to join the cluster. Supports multiple values separated by commas. Each value can be a hostname, an IP address, or a DNS name (A/AAAA and SRV records).")
f.BoolVar(&cfg.Debug, "ui.debug", false, "Enable debug logging for the UI.")
}

func (cfg Config) Validate() error {
Expand Down
8 changes: 5 additions & 3 deletions pkg/ui/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import (
"github.com/grafana/dskit/services"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/net/http2"

util_log "github.com/grafana/loki/v3/pkg/util/log"
)

// This allows to rate limit the number of updates when the cluster is frequently changing (e.g. during rollout).
Expand All @@ -42,7 +40,7 @@ type Service struct {
}

func NewService(cfg Config, router *mux.Router, logger log.Logger, reg prometheus.Registerer) (*Service, error) {
addr, err := ring.GetInstanceAddr(cfg.AdvertiseAddr, cfg.InfNames, util_log.Logger, cfg.EnableIPv6)
addr, err := ring.GetInstanceAddr(cfg.AdvertiseAddr, cfg.InfNames, logger, cfg.EnableIPv6)
if err != nil {
return nil, err
}
Expand All @@ -56,6 +54,10 @@ func NewService(cfg Config, router *mux.Router, logger log.Logger, reg prometheu
},
},
}

if !cfg.Debug {
logger = level.NewFilter(logger, level.AllowInfo())
}
advertiseAddr := fmt.Sprintf("%s:%d", cfg.AdvertiseAddr, cfg.AdvertisePort)
node, err := ckit.NewNode(httpClient, ckit.Config{
Name: cfg.NodeName,
Expand Down
2 changes: 1 addition & 1 deletion production/helm/loki/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ loki:
ui:
discovery:
join_peers:
- '{{ include "loki.distributorFullname" . }}.{{ $.Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}'
- '{{ include "loki.queryFrontendFullname" . }}.{{ $.Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}'
{{- end }}
{{- with .Values.loki.querier }}
querier:
Expand Down

0 comments on commit aa0b1f2

Please sign in to comment.