Skip to content

Commit

Permalink
T7190: Add haproxy default timeout options configurable
Browse files Browse the repository at this point in the history
Add the ability to configurate default timeout and frontend
client timeout

```
set load-balancing haproxy service web timeout client '600'
set load-balancing haproxy timeout check '4'
set load-balancing haproxy timeout client '600'
set load-balancing haproxy timeout connect '12'
set load-balancing haproxy timeout server '120'
```
  • Loading branch information
sever-sever committed Feb 22, 2025
1 parent 5d9d232 commit fccd573
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 39 deletions.
12 changes: 9 additions & 3 deletions data/templates/load-balancing/haproxy.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ defaults
log global
mode http
option dontlognull
timeout connect 10s
timeout client 50s
timeout server 50s
timeout check {{ timeout.check }}s
timeout connect {{ timeout.connect }}s
timeout client {{ timeout.client }}s
timeout server {{ timeout.server }}s
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
Expand Down Expand Up @@ -134,6 +135,11 @@ frontend {{ front }}
default_backend {{ backend }}
{% endfor %}
{% endif %}
{% if front_config.timeout is vyos_defined %}
{% if front_config.timeout.client is vyos_defined %}
timeout client {{ front_config.timeout.client }}
{% endif %}
{% endif %}

{% endfor %}
{% endif %}
Expand Down
14 changes: 14 additions & 0 deletions interface-definitions/include/haproxy/timeout-check.xml.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!-- include start from haproxy/timeout-check.xml.i -->
<leafNode name="check">
<properties>
<help>Timeout in seconds for established connections</help>
<valueHelp>
<format>u32:1-3600</format>
<description>Check timeout in seconds</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 1-3600"/>
</constraint>
</properties>
</leafNode>
<!-- include end -->
14 changes: 14 additions & 0 deletions interface-definitions/include/haproxy/timeout-client.xml.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!-- include start from haproxy/timeout-client.xml.i -->
<leafNode name="client">
<properties>
<help>Maximum inactivity time on the client side</help>
<valueHelp>
<format>u32:1-3600</format>
<description>Timeout in seconds</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 1-3600"/>
</constraint>
</properties>
</leafNode>
<!-- include end -->
14 changes: 14 additions & 0 deletions interface-definitions/include/haproxy/timeout-connect.xml.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!-- include start from haproxy/timeout-connect.xml.i -->
<leafNode name="connect">
<properties>
<help>Set the maximum time to wait for a connection attempt to a server to succeed</help>
<valueHelp>
<format>u32:1-3600</format>
<description>Connect timeout in seconds</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 1-3600"/>
</constraint>
</properties>
</leafNode>
<!-- include end -->
14 changes: 14 additions & 0 deletions interface-definitions/include/haproxy/timeout-server.xml.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!-- include start from haproxy/timeout-server.xml.i -->
<leafNode name="server">
<properties>
<help>Set the maximum inactivity time on the server side</help>
<valueHelp>
<format>u32:1-3600</format>
<description>Server timeout in seconds</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 1-3600"/>
</constraint>
</properties>
</leafNode>
<!-- include end -->
39 changes: 3 additions & 36 deletions interface-definitions/include/haproxy/timeout.xml.i
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,9 @@
<help>Timeout options</help>
</properties>
<children>
<leafNode name="check">
<properties>
<help>Timeout in seconds for established connections</help>
<valueHelp>
<format>u32:1-3600</format>
<description>Check timeout in seconds</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 1-3600"/>
</constraint>
</properties>
</leafNode>
<leafNode name="connect">
<properties>
<help>Set the maximum time to wait for a connection attempt to a server to succeed</help>
<valueHelp>
<format>u32:1-3600</format>
<description>Connect timeout in seconds</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 1-3600"/>
</constraint>
</properties>
</leafNode>
<leafNode name="server">
<properties>
<help>Set the maximum inactivity time on the server side</help>
<valueHelp>
<format>u32:1-3600</format>
<description>Server timeout in seconds</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 1-3600"/>
</constraint>
</properties>
</leafNode>
#include <include/haproxy/timeout-check.xml.i>
#include <include/haproxy/timeout-connect.xml.i>
#include <include/haproxy/timeout-server.xml.i>
</children>
</node>
<!-- include end -->
31 changes: 31 additions & 0 deletions interface-definitions/load-balancing_haproxy.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@
<valueless/>
</properties>
</leafNode>
<node name="timeout">
<properties>
<help>Timeout options</help>
</properties>
<children>
#include <include/haproxy/timeout-client.xml.i>
</children>
</node>
<node name="http-compression">
<properties>
<help>Compress HTTP responses</help>
Expand Down Expand Up @@ -368,6 +376,29 @@
</leafNode>
</children>
</node>
<node name="timeout">
<properties>
<help>Timeout options</help>
</properties>
<children>
#include <include/haproxy/timeout-check.xml.i>
<leafNode name="check">
<defaultValue>5</defaultValue>
</leafNode>
#include <include/haproxy/timeout-connect.xml.i>
<leafNode name="connect">
<defaultValue>10</defaultValue>
</leafNode>
#include <include/haproxy/timeout-client.xml.i>
<leafNode name="client">
<defaultValue>50</defaultValue>
</leafNode>
#include <include/haproxy/timeout-server.xml.i>
<leafNode name="server">
<defaultValue>50</defaultValue>
</leafNode>
</children>
</node>
#include <include/interface/vrf.xml.i>
</children>
</node>
Expand Down

0 comments on commit fccd573

Please sign in to comment.