Backport of agent: prevent very old servers re-joining a cluster with stale data into release/1.15.x #17354
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport
This PR is auto-generated from #17171 to be assessed for backporting due to the inclusion of the label backport/1.15.
🚨
The person who merged in the original PR is:
@loshz
This person should manually cherry-pick the original PR into a new backport PR,
and close this one when the manual backport PR is merged in.
The below text is copied from the body of the original PR.
Description
This PR introduces the concept of Server Metadata, which is server specific information written to a file stored in the configured data directory. During this initial phase, we only store the last seen timestamp in Unix format:
consul/agent/consul/server_metadata.go
Lines 17 to 19 in 5103a1a
2 new agent methods for attempting to prevent old servers from rejoining an existing cluster.
persistServerMetadata()
: Periodically write a server's metadata to a file in the configured data directory every hour.checkServerLastSeen()
: Attempt to read a server's last seen file and check the Unix timestamp against a configurable max age. If the last seen file does not exist, we treat this as an initial startup and return no error.Example
We attempt to start a previously running server with the following last seen timestamp
1672531200
(2023-Jan-01 00:00:00).Setting the new config to
server_rejoin_age_max = "3d"
will prevent this server from starting and require an operator to manually remove this file from the data directory if they need to force the server to rejoin.Testing & Reproduction steps
Links
PR Checklist
Overview of commits