Repository navigation
Support opt-in HAProxy backend address discovery - #208
Merged
Merged
Conversation
Preserve default hostname-based discovery while allowing selected pools to use validated backend host and port values from the HAProxy CSV addr field. Carry backend ports through status filtering and probe inventory creation, with regression tests and configuration documentation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: fbc83df2-d1af-406f-b97b-51cf0aaa570d
There was a problem hiding this comment.
🟡 Changes recommended
With UseServerAddress enabled, address validation of ineligible maintenance rows and incorrect parsing of quoted CSV fields can prevent otherwise valid servers from being discovered.
3 open issues
What changed in this PR
Adds opt-in HAProxy discovery from each server’s addr field, preserving the destination port while keeping hostname-based discovery as the default.
Changes:
- Adds per-cluster configuration and address parsing for IPv4, IPv6, and hostname targets.
- Preserves discovered ports through filtering and MySQL probe creation.
- Documents the option and adds parser and inventory regression tests.
| File | Description |
|---|---|
pkg/throttle/throttler.go |
Selects discovery mode and preserves target ports in probes. |
pkg/throttle/haproxy_inventory_test.go |
Tests compatibility, exclusions, ports, and target changes. |
pkg/haproxy/throttle.go |
Adds filtering that retains backend objects and ports. |
pkg/haproxy/server_address_test.go |
Tests address parsing, validation, and status filtering. |
pkg/haproxy/parser.go |
Adds opt-in parsing and validation of server addresses. |
pkg/haproxy/host.go |
Adds the discovered port to backend hosts. |
pkg/config/haproxy_config.go |
Adds the UseServerAddress setting. |
doc/mysql.md |
Documents configuration and discovery failure behavior. |
Review effort: Max (adaptive)
narlapuramsatya
approved these changes
Nov 19, 2026
narlapuramsatya
left a comment
There was a problem hiding this comment.
I am not familiar with where and how the HAProxy are used. Please get it reviewed someone with more familiar in this space.
Decode quoted CSV records correctly and validate backend addresses only for servers eligible for probing. Preserve transition safeguards, add parser and inventory regressions, and document the HTTP stats address prerequisite. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: fbc83df2-d1af-406f-b97b-51cf0aaa570d
CameronSmith13
approved these changes
Nov 19, 2026
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.


Why
HAProxy's
svnameis a server label, which is not necessarily a resolvablehostname. For example, a row can have
svname=primarywhile its actual destinationis in
addr=192.0.2.10:3307. Freno currently treats the label as the MySQL hostnameand uses the cluster's configured MySQL port.
Add a per-cluster
HAProxySettings.UseServerAddressoption to discover thedestination from
addrinstead. It defaults tofalse, preserving existinghostname-based discovery.
Call flow
The two similarly named files have different responsibilities:
pkg/throttle/throttler.gocoordinates discovery and creates MySQL probes.pkg/haproxy/throttle.goselects which discovered servers should be probed.For the illustrative
primaryrow above, enabling the option produces a probefor
192.0.2.10:3307, rather thanprimarywith the configured cluster port.The address is split because the existing
mysql.InstanceKeyand connectionbuilder already represent hostname and port separately.
Previously,
totalHostscontained only hostname strings. It now containsbackend objects so the address's port survives filtering and inventory creation.
The existing hostname-only
FilterThrotllerHosts()function remains availableand reuses the same filtering implementation.
Configuration and compatibility
Set the option inside the selected cluster's existing
HAProxySettings:false, discovery still usessvnameand theconfigured MySQL port. CSVs without an
addrcolumn remain supported.addr, including nondefaultports, and supports bracketed IPv6 addresses.
IgnoreHostsand skipped-hostchecks apply to the discovered target rather than the HAProxy label.
UP,DOWN, andno checkserversremain eligible; transitioning
UP,NOLB, and unrecognized statuses areexcluded. Existing all-transitioning discovery safeguards remain in place.
empty hosts, and unspecified IP addresses. Invalid selected-server addresses
do not fall back to their labels or return a partially parsed roster.
An unsuccessful HAProxy refresh can still retain the previous inventory; this
change does not add a new stale-discovery or fail-closed policy.
Deploy a binary supporting this option before enabling it in configuration.
No deployment or configuration rollout is included.
Validation
script/cibuildusing the existing local Go 1.27.3 Docker image:formatting, binary build, and all package tests with race detection.
fields, summary rows, and status/transition filtering.
identical aliases in different pools, nondefault ports, IPv6, address-based
exclusions, and replacing the old probe target after a simulated address
change.
a98258889e1e4caa352c9604fb37d59ddb8c48eewithout conflicts and passed thecombined HAProxy, config, throttle, and HTTP race tests. This PR is independent
of Add composite MySQL safety checks and stable recovery #196 and does not modify its branch.
These are local code and simulated-discovery checks, not production connectivity
or failover validation.