Skip to content

Allow specifying persistent peer ids#3014

Closed
sinkingpoint wants to merge 2 commits intoprometheus:mainfrom
sinkingpoint:sinkingpoint/persistant_peer_ids
Closed

Allow specifying persistent peer ids#3014
sinkingpoint wants to merge 2 commits intoprometheus:mainfrom
sinkingpoint:sinkingpoint/persistant_peer_ids

Conversation

@sinkingpoint
Copy link
Contributor

Currently the default behaviour is to generate a new, random peer id on
every startup. This makes clustering a bit weird, so this commit adds in
an optional cli arg that allows specifying a custom peer id that we can
persist across runs

This addresses #2285

Signed-off-by: sinkingpoint colin@quirl.co.nz

@sinkingpoint sinkingpoint force-pushed the sinkingpoint/persistant_peer_ids branch from 179b407 to 7bc0cf7 Compare July 21, 2022 04:40
Copy link
Member

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! As I said in #2285, I see no real reason why the peer names are auto-generated. And in kubernetes land, we could rely on the statefulset names to guarantee uniqueness.

It would be nice to have a new acceptance test to verify that it works. I've tested locally and it seems to work fine though name conflicts aren't easy to detect (they appear in the memberlist logs but those are only available at the debug level). I suppose that we'd need to implement the ConflictDelegate interface (https://pkg.go.dev/github.com/hashicorp/memberlist#ConflictDelegate) for the delegate struct?

clusterBindAddr = kingpin.Flag("cluster.listen-address", "Listen address for cluster. Set to empty string to disable HA mode.").
Default(defaultClusterAddr).String()
clusterAdvertiseAddr = kingpin.Flag("cluster.advertise-address", "Explicit address to advertise in cluster.").String()
clusterPeerName = kingpin.Flag("cluster.peer-name", "Explicit name of the peer, rather than generating a random one").Default("").String()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe insist that peer names should be unique across all nodes of the cluster?

@sinkingpoint sinkingpoint force-pushed the sinkingpoint/persistant_peer_ids branch from 7bc0cf7 to 89eefc9 Compare August 8, 2022 04:07
@sinkingpoint
Copy link
Contributor Author

Thanks for the review @simonpasquier ! I've added in an acceptance test to test the behaviour. Detecting duplicate names is an interesting problem... Yes - we can implement the ConflictDelegate interface, but the question is what to do with that information - we can log it (easy), or attempt to shut down one of the duplicates, but that, in practice gets a bit messy. In particular, identifying which peer is the "invalid" one is kind of difficult - memberlist doesn't have the idea of an "authoritative" node for a given name

@simonpasquier
Copy link
Member

Sorry for the lag (PTO interruption on my side). I agree that there's no practical that we can decide which peer is more legitimate than the other. I think that logging the issue + adding a metric/alert would be good enough. WDYT?

@sinkingpoint
Copy link
Contributor Author

Apologies for leaving this... I think that sounds reasonable. Will push that today

Currently the default behaviour is to generate a new, random peer id on
every startup. This makes clustering a bit weird, so this commit adds in
an optional cli arg that allows specifying a custom peer id that we can
persist across runs

Signed-off-by: sinkingpoint <colin@quirl.co.nz>
@sinkingpoint sinkingpoint force-pushed the sinkingpoint/persistant_peer_ids branch from 89eefc9 to 15904d6 Compare January 30, 2023 23:32
This adds in the delegate as a `memberlist.ConflictDelegate` so
that we get a callback when we encounter conflicts in peer ids which
we then log and increment a new metric to allow monitoring the conflict
condition

Signed-off-by: sinkingpoint <colin@quirl.co.nz>
@sinkingpoint sinkingpoint force-pushed the sinkingpoint/persistant_peer_ids branch from 15904d6 to c32479d Compare January 31, 2023 00:22
@SuperQ
Copy link
Member

SuperQ commented Oct 31, 2025

Fixed in #4636

@SuperQ SuperQ closed this Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants