Merge pull request #21 from fraenki/haproxy_checkport

net/haproxy: enhance "checkport" option & more fixes
This commit is contained in:
Franco Fichtner 2016-06-13 17:18:56 +02:00 committed by GitHub
commit 6cf489906b
3 changed files with 24 additions and 4 deletions

View file

@ -23,6 +23,13 @@
<type>text</type>
<help><![CDATA[Select interval (in milliseconds) between two consecutive health checks.]]></help>
</field>
<field>
<id>healthcheck.checkport</id>
<label>Port to check</label>
<type>text</type>
<help><![CDATA[Provide the TCP communication port to use during check, i.e. 80 or 443.]]></help>
<advanced>true</advanced>
</field>
<field>
<label>HTTP check options</label>
<type>header</type>

View file

@ -549,7 +549,7 @@
<Required>Y</Required>
</port>
<checkport type="IntegerField">
<default>80</default>
<default></default>
<MinimumValue>1</MinimumValue>
<MaximumValue>65535</MaximumValue>
<ValidationMessage>Please specify a value between 1 and 65535.</ValidationMessage>
@ -624,6 +624,13 @@
<ValidationMessage>Please specify a value between 250 and 1000000.</ValidationMessage>
<Required>N</Required>
</interval>
<checkport type="IntegerField">
<default></default>
<MinimumValue>1</MinimumValue>
<MaximumValue>65535</MaximumValue>
<ValidationMessage>Please specify a value between 1 and 65535.</ValidationMessage>
<Required>N</Required>
</checkport>
<!-- XXX: add tag <http> once nesting is supported by our framework -->
<http_method type="OptionField">
<Required>N</Required>

View file

@ -652,7 +652,7 @@ backend {{backend.name}}
{# # health check option #}
{% set healthcheck_options = [] %}
{% if healthcheck_data.type|default("") == "" %}
{% set healthcheck_enabled = '1' %}
{% set healthcheck_enabled = '0' %}
{% elif healthcheck_data.type == 'tcp' %}
{# # TCP check does not require additional options #}
{% elif healthcheck_data.type == 'http' %}
@ -763,15 +763,21 @@ backend {{backend.name}}
{% if backend.tuning_defaultserver|default("") != "" %}
default-server {{backend.tuning_defaultserver}}
{% endif %}
{% for server in backend.linkedServers.split(",") %}
{% set server_data = helpers.getUUID(server) %}
{# # collect optional server parameters #}
{% set server_options = [] %}
{# if# check if health check is enabled #}("") != "" %}
{# # check if health check is enabled #}
{% if healthcheck_enabled == '1' %}
{% do server_options.append('check') %}
{% do server_options.append('inter ' ~ server_data.checkInterval) %}
{# # use a different port for health check #}
{% if healthcheck_data.checkport|default("") != "" %}
{# # prefer port from health check template #}
{% do server_options.append('port ' ~ healthcheck_data.checkport) %}
{% elif server_data.checkport|default("") != "" %}
{% do server_options.append('port ' ~ server_data.checkport) %}
{% endif %}
{# # add all additions from healthchecks here #}
{% do server_options.append(healthcheck_additions|join(' ')) if healthcheck_additions.length != '0' %}
{% endif %}