Clean server rename#17
Open
alexanderstephan wants to merge 3 commits into
Open
Conversation
749d535 to
d519e65
Compare
f28cd5a to
c7d835a
Compare
…ommand for runtime server renaming
Add the ability to rename a HAProxy server at runtime via the CLI
command:
set server <backend>/<server> name <newname>
This is useful in slot-based dynamic scaling setups where servers are
pre-allocated with generic names (e.g. srv001, srv002) but the operator
wants the names to reflect the current workload (e.g. pod name or
IP:port) for observability and server-state-file consistency.
A per-backend opt-in directive 'option server-rename' is required to
allow renaming. It may be placed in a defaults section to apply to all
backends without per-backend configuration.
The implementation:
- validates the new name: non-empty, passes invalid_char() check
(allows [A-Za-z0-9_:.-]), and fits in the event data name field
- requires the server to be administratively in maintenance mode
- rejects rename if the server has SRV_F_NON_PURGEABLE set (covers
servers referenced by a static 'use-server' rule, servers tracked
by another server via 'track', servers used by resolvers, and other
configuration elements pointing to the server)
- re-indexes the server in the cebtree under thread_isolate()
- publishes a new EVENT_HDL_SUB_SERVER_NAME event with old/new names
Note: sample fetches with ARG_SRV arguments (srv_queue(), srv_conn(),
srv_is_up(), etc.) are resolved to pointers at config-check time and
will continue to work after a rename, but leave the config text
inconsistent with the running state. Operators should audit their ACL
expressions manually before renaming a server.
This feature was discussed in:
haproxy#952
Tests cover:
- error cases: missing name, no opt-in, not-in-maintenance, invalid
chars, duplicate name, non-purgeable server (use-server reference,
track reference)
- same-name rename as a no-op success
- successful rename with verification via 'show servers state'
- old name no longer resolves after rename
- round-trip rename back to original name
- traffic still works after rename round-trip
…I command Document the new 'option server-rename' backend directive and the 'set server <b>/<s> name <newname>' CLI command in configuration.txt and management.txt respectively.
c7d835a to
d40bcde
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.