Skip to content

Commit

Permalink
Cluster: Add memberlist label configuration option (#3354)
Browse files Browse the repository at this point in the history
* Cluster: Add memberlist label configuration option

Signed-off-by: Jean-Philippe Quémémer <jeanphilippe.quemener@grafana.com>

---------

Signed-off-by: Jean-Philippe Quémémer <jeanphilippe.quemener@grafana.com>
Signed-off-by: Jean-Philippe Quéméner <JohnnyQQQQ@users.noreply.github.com>
Co-authored-by: gotjosh <josue.abreu@gmail.com>
  • Loading branch information
JohnnyQQQQ and gotjosh committed Aug 7, 2023
1 parent 0d4533a commit 60b0416
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ be configured to communicate with each other. This is configured using the
- `--cluster.probe-interval` value: interval between random node probes (default "1s")
- `--cluster.reconnect-interval` value: interval between attempting to reconnect to lost peers (default "10s")
- `--cluster.reconnect-timeout` value: length of time to attempt to reconnect to a lost peer (default: "6h0m0s")
- `--cluster.label` value: the label is an optional string to include on each packet and stream. It uniquely identifies the cluster and prevents cross-communication issues when sending gossip messages (default:"")

The chosen port in the `cluster.listen-address` flag is the port that needs to be
specified in the `cluster.peer` flag of the other peers.
Expand Down
2 changes: 2 additions & 0 deletions cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ func Create(
probeInterval time.Duration,
tlsTransportConfig *TLSTransportConfig,
allowInsecureAdvertise bool,
label string,
) (*Peer, error) {
bindHost, bindPortStr, err := net.SplitHostPort(bindAddr)
if err != nil {
Expand Down Expand Up @@ -227,6 +228,7 @@ func Create(
cfg.LogOutput = &logWriter{l: l}
cfg.GossipNodes = retransmit
cfg.UDPBufferSize = MaxGossipPacketSize
cfg.Label = label

if advertiseHost != "" {
cfg.AdvertiseAddr = advertiseHost
Expand Down
8 changes: 8 additions & 0 deletions cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func testJoinLeave(t *testing.T) {
DefaultProbeInterval,
nil,
false,
"",
)
require.NoError(t, err)
require.NotNil(t, p)
Expand Down Expand Up @@ -88,6 +89,7 @@ func testJoinLeave(t *testing.T) {
DefaultProbeInterval,
nil,
false,
"",
)
require.NoError(t, err)
require.NotNil(t, p2)
Expand Down Expand Up @@ -123,6 +125,7 @@ func testReconnect(t *testing.T) {
DefaultProbeInterval,
nil,
false,
"",
)
require.NoError(t, err)
require.NotNil(t, p)
Expand All @@ -148,6 +151,7 @@ func testReconnect(t *testing.T) {
DefaultProbeInterval,
nil,
false,
"",
)
require.NoError(t, err)
require.NotNil(t, p2)
Expand Down Expand Up @@ -188,6 +192,7 @@ func testRemoveFailedPeers(t *testing.T) {
DefaultProbeInterval,
nil,
false,
"",
)
require.NoError(t, err)
require.NotNil(t, p)
Expand Down Expand Up @@ -239,6 +244,7 @@ func testInitiallyFailingPeers(t *testing.T) {
DefaultProbeInterval,
nil,
false,
"",
)
require.NoError(t, err)
require.NotNil(t, p)
Expand Down Expand Up @@ -286,6 +292,7 @@ func testTLSConnection(t *testing.T) {
DefaultProbeInterval,
tlsTransportConfig1,
false,
"",
)
require.NoError(t, err)
require.NotNil(t, p1)
Expand Down Expand Up @@ -317,6 +324,7 @@ func testTLSConnection(t *testing.T) {
DefaultProbeInterval,
tlsTransportConfig2,
false,
"",
)
require.NoError(t, err)
require.NotNil(t, p2)
Expand Down
2 changes: 2 additions & 0 deletions cmd/alertmanager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ func run() int {
peerReconnectTimeout = kingpin.Flag("cluster.reconnect-timeout", "Length of time to attempt to reconnect to a lost peer.").Default(cluster.DefaultReconnectTimeout.String()).Duration()
tlsConfigFile = kingpin.Flag("cluster.tls-config", "[EXPERIMENTAL] Path to config yaml file that can enable mutual TLS within the gossip protocol.").Default("").String()
allowInsecureAdvertise = kingpin.Flag("cluster.allow-insecure-public-advertise-address-discovery", "[EXPERIMENTAL] Allow alertmanager to discover and listen on a public IP address.").Bool()
label = kingpin.Flag("cluster.label", "The cluster label is an optional string to include on each packet and stream. It uniquely identifies the cluster and prevents cross-communication issues when sending gossip messages.").Default("").String()
)

promlogflag.AddFlags(kingpin.CommandLine, &promlogConfig)
Expand Down Expand Up @@ -267,6 +268,7 @@ func run() int {
*probeInterval,
tlsTransportConfig,
*allowInsecureAdvertise,
*label,
)
if err != nil {
level.Error(logger).Log("msg", "unable to initialize gossip mesh", "err", err)
Expand Down

0 comments on commit 60b0416

Please sign in to comment.