Skip to content

Commit b22b160

Browse files
committed
Parameterize haproxy's http check timeout
1 parent 1ce8aa4 commit b22b160

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

Diff for: manifests/haproxy/service.pp

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2019 The Regents of the University of Michigan.
1+
# Copyright (c) 2019, 2024 The Regents of the University of Michigan.
22
# All Rights Reserved. Licensed according to the terms of the Revised
33
# BSD License. See LICENSE.txt for details.
44

@@ -45,6 +45,9 @@
4545
# @param dynamic_weight_smoothing This value is added to the weight for each
4646
# backend server regardless of server load to help "smooth" the effect of the weighting
4747
#
48+
# @param check_timeout_milliseconds How long to wait for http status
49+
# checks; defaults to 5 seconds
50+
#
4851
# @example
4952
# nebula::haproxy::service { 'www-whatever':
5053
# floating_ip => '1.2.3.4'
@@ -70,7 +73,8 @@
7073
Hash $whitelists = {},
7174
Boolean $custom_503 = false,
7275
Boolean $dynamic_weighting = false,
73-
Integer $dynamic_weight_smoothing = 2
76+
Integer $dynamic_weight_smoothing = 2,
77+
Optional[Integer] $check_timeout_milliseconds = undef
7478
) {
7579

7680
include nebula::profile::haproxy::prereqs
@@ -144,6 +148,14 @@
144148
content => "option httpchk GET /monitor/monitor.pl\nhttp-check expect status 200\n",
145149
order => '02'
146150
}
151+
152+
if $check_timeout_milliseconds != undef {
153+
concat_fragment { "${service_prefix} check_timeout":
154+
target => $service_cfg,
155+
content => "timeout connect ${check_timeout_milliseconds}\n",
156+
order => '02'
157+
}
158+
}
147159
}
148160

149161
if($custom_503) {

Diff for: spec/defines/haproxy_service_spec.rb

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
# Copyright (c) 2018 The Regents of the University of Michigan.
3+
# Copyright (c) 2018, 2024 The Regents of the University of Michigan.
44
# All Rights Reserved. Licensed according to the terms of the Revised
55
# BSD License. See LICENSE.txt for details.
66
require 'spec_helper'
@@ -253,6 +253,20 @@
253253
.with_environment(['HAPROXY_SMOOTHING_FACTOR=2'])
254254
end
255255
end
256+
257+
it { is_expected.not_to contain_concat_fragment('svc1-dc1-https check_timeout') }
258+
259+
context 'with check_timeout_milliseconds set to 15000' do
260+
let(:params) do
261+
super().merge(check_timeout_milliseconds: 15000)
262+
end
263+
264+
it do
265+
is_expected.to contain_concat_fragment('svc1-dc1-https check_timeout')
266+
.with_target(service_config)
267+
.with_content("timeout connect 15000\n")
268+
end
269+
end
256270
end
257271

258272
describe 'http service config' do

0 commit comments

Comments
 (0)