Skip to content

Set "option forwardfor" by default for haproxy-route backends#550

Open
Copilot wants to merge 11 commits into
mainfrom
copilot/set-option-forwardfor-default
Open

Set "option forwardfor" by default for haproxy-route backends#550
Copilot wants to merge 11 commits into
mainfrom
copilot/set-option-forwardfor-default

Conversation

Copilot AI commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

What this PR does

Adds option forwardfor to every HTTP backend in the haproxy_route.cfg.j2 template. This causes HAProxy to set the X-Forwarded-For header on all proxied requests, allowing backend applications to identify the original client IP.

backend my-app_80
    option forwardfor
    balance roundrobin
    ...

Why we need it

Without this option, backend services behind haproxy-route have no way to determine the real client IP address — they only see the HAProxy instance IP. The legacy configuration already sets this option; this brings haproxy-route to parity.

Test plan

  • Added an assertion in the existing test_protocol_https unit test to verify option forwardfor is present in the rendered configuration.
  • All existing tests in test_haproxy_route_options.py continue to pass.

Review focus

  • Placement of option forwardfor as the first directive after the backend line — consistent with how the legacy code appends it.

Checklist

  • I followed the contributing guide
  • I added or updated the documentation (if applicable)
  • I updated docs/changelog.md with user-relevant changes
  • I added a change artifact for user-relevant changes in docs/release-notes/artifacts. If no change artifact is necessary, I tagged the PR with the label no-release-note.
  • I used AI to assist with preparing this PR
  • I added or updated tests as needed (unit and integration)
  • If integration test modules are used: I updated the workflow configuration
    (e.g., in .github/workflows/integration_tests.yaml, ensure the modules list is correct)
  • If this PR involves a Grafana dashboard: I added a screenshot of the dashboard
  • If this PR involves Terraform: terraform fmt passes and tflint reports no errors

Copilot AI changed the title [WIP] Update j2 template to set option forwardfor by default for backends Set "option forwardfor" by default for haproxy-route backends Jun 12, 2026
Copilot AI requested a review from Thanhphan1147 June 12, 2026 08:26
Comment thread haproxy-operator/tests/unit/test_haproxy_route_options.py Outdated
Comment thread docs/changelog.md Outdated
@Thanhphan1147 Thanhphan1147 marked this pull request as ready for review June 12, 2026 09:03
@Thanhphan1147 Thanhphan1147 requested a review from a team as a code owner June 12, 2026 09:03
…points

When haproxy processes a relation-changed event it calls publish_proxied_endpoints
for every valid TCP/HTTP frontend relation, not just the one that changed.
Any relation-set call — even writing the same value — triggers a relation-changed
on the requirer side (Juju tracks writes, not diffs). This creates an infinite loop:

  requirer writes → haproxy relation-changed
    → haproxy re-publishes to ALL relations (unchanged data)
      → requirer relation-changed for each
        → requirer re-publishes to all → ∞

Fix: compare current provider databag to the intended write before calling
dump(). Skip if the endpoints are already identical.

Reproduces: canonical/maas-charms#627
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants