Skip to content

Clean server rename#17

Open
alexanderstephan wants to merge 3 commits into
masterfrom
clean-server-rename
Open

Clean server rename#17
alexanderstephan wants to merge 3 commits into
masterfrom
clean-server-rename

Conversation

@alexanderstephan

Copy link
Copy Markdown
Collaborator

No description provided.

@alexanderstephan alexanderstephan force-pushed the clean-server-rename branch 3 times, most recently from 749d535 to d519e65 Compare June 18, 2026 13:00
@alexanderstephan alexanderstephan self-assigned this Jun 18, 2026
@alexanderstephan alexanderstephan force-pushed the clean-server-rename branch 5 times, most recently from f28cd5a to c7d835a Compare June 18, 2026 14:24
…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.
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.

1 participant