Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

Each revision is versioned by the date of the revision.

## 2026-04-21

- Do not render the default backend if there are no other backends in in the haproxy-route-tcp.

## 2026-04-17

- Added missing settings from haproxy-route-tcp relation template.
Expand Down
14 changes: 14 additions & 0 deletions docs/release-notes/artifacts/pr0476.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version_schema: 2
changes:
- title: Do not render the default backend if there are no other backends
author: skatsaounis
type: bugfix
description: >
Do not render the default backend if there are no other backends in the
haproxy-route-tcp relation template, to avoid rendering unused
configuration.
urls:
pr:
- https://github.com/canonical/haproxy-operator/pull/476
visibility: public
highlight: false
4 changes: 2 additions & 2 deletions haproxy-operator/templates/haproxy_route_tcp.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ backend {{ frontend.default_backend_name }}
{% endfor %}
{% endif %}

{# Render each backend for the frontend. #}
{% for backend in frontend.backends %}
{# Render each backend for the frontend. Skip rendering if there's only the default backend. #}
{% for backend in frontend.backends if frontend.backends|length > 1 %}
backend {{ backend.name }}
mode tcp
{% if backend.application_data.load_balancing %}
Expand Down
15 changes: 15 additions & 0 deletions haproxy-operator/tests/integration/test_haproxy_route_tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,18 @@ def test_haproxy_route_tcp(
"timeout queue 2s",
]
)

assert all(
entry in haproxy_config
for entry in [
"backend haproxy_route_tcp_4444_default_backend",
"default_backend haproxy_route_tcp_4444_default_backend",
]
)
assert all(
entry not in haproxy_config
for entry in [
f"{any_charm_haproxy_route_tcp_requirer}_4444",
f"default_backend {any_charm_haproxy_route_tcp_requirer}_4444",
]
)
Loading