From f98e430ef33335f50fbca6dbd6b3566e323c9960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Qu=C3=A9m=C3=A9mer?= Date: Fri, 5 May 2023 15:02:23 +0200 Subject: [PATCH 1/4] Cluster: Add memberlist label configuration option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jean-Philippe Quémémer --- README.md | 1 + cluster/cluster.go | 2 ++ cluster/cluster_test.go | 8 ++++++++ cmd/alertmanager/main.go | 2 ++ 4 files changed, 13 insertions(+) diff --git a/README.md b/README.md index fb47acae01..51472b9350 100644 --- a/README.md +++ b/README.md @@ -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: unique label to prevent cross-communication issues when running multiple clusters (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. diff --git a/cluster/cluster.go b/cluster/cluster.go index ba7fdb9e7f..2c7ee945e6 100644 --- a/cluster/cluster.go +++ b/cluster/cluster.go @@ -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 { @@ -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 diff --git a/cluster/cluster_test.go b/cluster/cluster_test.go index 87c31d1370..6c49854983 100644 --- a/cluster/cluster_test.go +++ b/cluster/cluster_test.go @@ -54,6 +54,7 @@ func testJoinLeave(t *testing.T) { DefaultProbeInterval, nil, false, + "", ) require.NoError(t, err) require.NotNil(t, p) @@ -88,6 +89,7 @@ func testJoinLeave(t *testing.T) { DefaultProbeInterval, nil, false, + "", ) require.NoError(t, err) require.NotNil(t, p2) @@ -123,6 +125,7 @@ func testReconnect(t *testing.T) { DefaultProbeInterval, nil, false, + "", ) require.NoError(t, err) require.NotNil(t, p) @@ -148,6 +151,7 @@ func testReconnect(t *testing.T) { DefaultProbeInterval, nil, false, + "", ) require.NoError(t, err) require.NotNil(t, p2) @@ -188,6 +192,7 @@ func testRemoveFailedPeers(t *testing.T) { DefaultProbeInterval, nil, false, + "", ) require.NoError(t, err) require.NotNil(t, p) @@ -239,6 +244,7 @@ func testInitiallyFailingPeers(t *testing.T) { DefaultProbeInterval, nil, false, + "", ) require.NoError(t, err) require.NotNil(t, p) @@ -286,6 +292,7 @@ func testTLSConnection(t *testing.T) { DefaultProbeInterval, tlsTransportConfig1, false, + "", ) require.NoError(t, err) require.NotNil(t, p1) @@ -317,6 +324,7 @@ func testTLSConnection(t *testing.T) { DefaultProbeInterval, tlsTransportConfig2, false, + "", ) require.NoError(t, err) require.NotNil(t, p2) diff --git a/cmd/alertmanager/main.go b/cmd/alertmanager/main.go index 5680e79ab8..5733420f5f 100644 --- a/cmd/alertmanager/main.go +++ b/cmd/alertmanager/main.go @@ -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", "A unique identifier for the cluster used to prevent cross-communication issues when sending gossip messages.").Default("").String() ) promlogflag.AddFlags(kingpin.CommandLine, &promlogConfig) @@ -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) From 53bac82cc3992090bab6b070d20e226f69c4aca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Qu=C3=A9m=C3=A9ner?= Date: Fri, 5 May 2023 18:04:52 +0200 Subject: [PATCH 2/4] Update cmd/alertmanager/main.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: gotjosh Signed-off-by: Jean-Philippe Quéméner --- cmd/alertmanager/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/alertmanager/main.go b/cmd/alertmanager/main.go index 5733420f5f..9998e88dad 100644 --- a/cmd/alertmanager/main.go +++ b/cmd/alertmanager/main.go @@ -226,7 +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", "A unique identifier for the cluster used to prevent cross-communication issues when sending gossip messages.").Default("").String() + 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) From d262f10d516242396f2bbafcc97fa7fadd4a22a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Qu=C3=A9m=C3=A9ner?= Date: Fri, 5 May 2023 18:14:39 +0200 Subject: [PATCH 3/4] Update README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jean-Philippe Quéméner --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 51472b9350..4b3eed11a5 100644 --- a/README.md +++ b/README.md @@ -372,7 +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: unique label to prevent cross-communication issues when running multiple clusters (default:"") +- `--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. From 0b8f08c14c055ef021a031829935d94f5dd5cd93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Qu=C3=A9m=C3=A9ner?= Date: Fri, 5 May 2023 18:15:18 +0200 Subject: [PATCH 4/4] Update README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jean-Philippe Quéméner --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4b3eed11a5..980f3d9635 100644 --- a/README.md +++ b/README.md @@ -372,7 +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:"") +- `--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.