Skip to content

Commit b3b374f

Browse files
committed
fix: health check timeout for services/NLB
The annotation for health check timeout was not consumed at all for services
1 parent b5e9427 commit b3b374f

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

pkg/service/model_build_target_group.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ func (t *defaultModelBuildTask) buildTargetGroupHealthCheckConfigDefault(ctx con
113113
if err != nil {
114114
return nil, err
115115
}
116+
healthCheckTimeoutSeconds, err := t.buildTargetGroupHealthCheckTimeoutSeconds(ctx, t.defaultHealthCheckTimeout)
117+
if err != nil {
118+
return nil, err
119+
}
116120
healthyThresholdCount, err := t.buildTargetGroupHealthCheckHealthyThresholdCount(ctx, t.defaultHealthCheckHealthyThreshold)
117121
if err != nil {
118122
return nil, err
@@ -126,6 +130,7 @@ func (t *defaultModelBuildTask) buildTargetGroupHealthCheckConfigDefault(ctx con
126130
Protocol: &healthCheckProtocol,
127131
Path: healthCheckPathPtr,
128132
IntervalSeconds: &intervalSeconds,
133+
TimeoutSeconds: &healthCheckTimeoutSeconds,
129134
HealthyThresholdCount: &healthyThresholdCount,
130135
UnhealthyThresholdCount: &unhealthyThresholdCount,
131136
}, nil
@@ -148,6 +153,10 @@ func (t *defaultModelBuildTask) buildTargetGroupHealthCheckConfigForInstanceMode
148153
if err != nil {
149154
return nil, err
150155
}
156+
healthCheckTimeoutSeconds, err := t.buildTargetGroupHealthCheckTimeoutSeconds(ctx, t.defaultHealthCheckTimeoutForInstanceModeLocal)
157+
if err != nil {
158+
return nil, err
159+
}
151160
healthyThresholdCount, err := t.buildTargetGroupHealthCheckHealthyThresholdCount(ctx, t.defaultHealthCheckHealthyThresholdForInstanceModeLocal)
152161
if err != nil {
153162
return nil, err
@@ -161,6 +170,7 @@ func (t *defaultModelBuildTask) buildTargetGroupHealthCheckConfigForInstanceMode
161170
Protocol: &healthCheckProtocol,
162171
Path: healthCheckPathPtr,
163172
IntervalSeconds: &intervalSeconds,
173+
TimeoutSeconds: &healthCheckTimeoutSeconds,
164174
HealthyThresholdCount: &healthyThresholdCount,
165175
UnhealthyThresholdCount: &unhealthyThresholdCount,
166176
}, nil

pkg/service/model_build_target_group_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ func Test_defaultModelBuilderTask_buildTargetHealthCheck(t *testing.T) {
183183
Port: &trafficPort,
184184
Protocol: (*elbv2.Protocol)(aws.String(string(elbv2.ProtocolTCP))),
185185
IntervalSeconds: aws.Int64(10),
186+
TimeoutSeconds: aws.Int64(10),
186187
HealthyThresholdCount: aws.Int64(3),
187188
UnhealthyThresholdCount: aws.Int64(3),
188189
},
@@ -209,6 +210,7 @@ func Test_defaultModelBuilderTask_buildTargetHealthCheck(t *testing.T) {
209210
Protocol: (*elbv2.Protocol)(aws.String("HTTP")),
210211
Path: aws.String("/healthz"),
211212
IntervalSeconds: aws.Int64(10),
213+
TimeoutSeconds: aws.Int64(30),
212214
HealthyThresholdCount: aws.Int64(2),
213215
UnhealthyThresholdCount: aws.Int64(2),
214216
},
@@ -229,6 +231,7 @@ func Test_defaultModelBuilderTask_buildTargetHealthCheck(t *testing.T) {
229231
Protocol: (*elbv2.Protocol)(aws.String("HTTP")),
230232
Path: aws.String("/"),
231233
IntervalSeconds: aws.Int64(10),
234+
TimeoutSeconds: aws.Int64(10),
232235
HealthyThresholdCount: aws.Int64(3),
233236
UnhealthyThresholdCount: aws.Int64(3),
234237
},
@@ -284,6 +287,7 @@ func Test_defaultModelBuilderTask_buildTargetHealthCheck(t *testing.T) {
284287
Port: &trafficPort,
285288
Protocol: (*elbv2.Protocol)(aws.String(string(elbv2.ProtocolTCP))),
286289
IntervalSeconds: aws.Int64(10),
290+
TimeoutSeconds: aws.Int64(10),
287291
HealthyThresholdCount: aws.Int64(3),
288292
UnhealthyThresholdCount: aws.Int64(3),
289293
},
@@ -304,6 +308,7 @@ func Test_defaultModelBuilderTask_buildTargetHealthCheck(t *testing.T) {
304308
Protocol: (*elbv2.Protocol)(aws.String(string(elbv2.ProtocolHTTP))),
305309
Path: aws.String("/healthz"),
306310
IntervalSeconds: aws.Int64(10),
311+
TimeoutSeconds: aws.Int64(6),
307312
HealthyThresholdCount: aws.Int64(2),
308313
UnhealthyThresholdCount: aws.Int64(2),
309314
},
@@ -333,6 +338,7 @@ func Test_defaultModelBuilderTask_buildTargetHealthCheck(t *testing.T) {
333338
Port: &port8888,
334339
Protocol: (*elbv2.Protocol)(aws.String(string(elbv2.ProtocolTCP))),
335340
IntervalSeconds: aws.Int64(10),
341+
TimeoutSeconds: aws.Int64(30),
336342
HealthyThresholdCount: aws.Int64(5),
337343
UnhealthyThresholdCount: aws.Int64(5),
338344
},

pkg/service/model_builder_test.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
190190
"port":"traffic-port",
191191
"protocol":"TCP",
192192
"intervalSeconds":10,
193+
"timeoutSeconds":10,
193194
"healthyThresholdCount":3,
194195
"unhealthyThresholdCount":3
195196
},
@@ -334,6 +335,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
334335
"port":"traffic-port",
335336
"protocol":"TCP",
336337
"intervalSeconds":10,
338+
"timeoutSeconds":10,
337339
"healthyThresholdCount":3,
338340
"unhealthyThresholdCount":3
339341
},
@@ -518,6 +520,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
518520
"protocol":"HTTP",
519521
"path":"/healthz",
520522
"intervalSeconds":10,
523+
"timeoutSeconds":30,
521524
"healthyThresholdCount":2,
522525
"unhealthyThresholdCount":2
523526
},
@@ -541,6 +544,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
541544
"protocol":"HTTP",
542545
"path":"/healthz",
543546
"intervalSeconds":10,
547+
"timeoutSeconds":30,
544548
"healthyThresholdCount":2,
545549
"unhealthyThresholdCount":2
546550
},
@@ -852,6 +856,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
852856
"protocol":"HTTP",
853857
"path":"/healthz",
854858
"intervalSeconds":10,
859+
"timeoutSeconds":30,
855860
"healthyThresholdCount":2,
856861
"unhealthyThresholdCount":2
857862
},
@@ -875,6 +880,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
875880
"protocol":"HTTP",
876881
"path":"/healthz",
877882
"intervalSeconds":10,
883+
"timeoutSeconds":30,
878884
"healthyThresholdCount":2,
879885
"unhealthyThresholdCount":2
880886
},
@@ -1180,6 +1186,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
11801186
"port": "traffic-port",
11811187
"protocol":"TCP",
11821188
"intervalSeconds":10,
1189+
"timeoutSeconds":10,
11831190
"healthyThresholdCount":3,
11841191
"unhealthyThresholdCount":3
11851192
},
@@ -1202,6 +1209,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
12021209
"port":"traffic-port",
12031210
"protocol":"TCP",
12041211
"intervalSeconds":10,
1212+
"timeoutSeconds":10,
12051213
"healthyThresholdCount":3,
12061214
"unhealthyThresholdCount":3
12071215
},
@@ -1448,8 +1456,9 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
14481456
"healthCheckConfig":{
14491457
"port": 29123,
14501458
"protocol":"HTTP",
1451-
"path":"/healthz",
1459+
"path":"/healthz",
14521460
"intervalSeconds":10,
1461+
"timeoutSeconds":6,
14531462
"healthyThresholdCount":2,
14541463
"unhealthyThresholdCount":2
14551464
},
@@ -1471,8 +1480,9 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
14711480
"healthCheckConfig":{
14721481
"port": 29123,
14731482
"protocol":"HTTP",
1474-
"path":"/healthz",
1483+
"path":"/healthz",
14751484
"intervalSeconds":10,
1485+
"timeoutSeconds":6,
14761486
"healthyThresholdCount":2,
14771487
"unhealthyThresholdCount":2
14781488
},
@@ -1729,6 +1739,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
17291739
"port":"traffic-port",
17301740
"protocol":"TCP",
17311741
"intervalSeconds":10,
1742+
"timeoutSeconds":10,
17321743
"healthyThresholdCount":3,
17331744
"unhealthyThresholdCount":3
17341745
},
@@ -1941,7 +1952,8 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
19411952
"unhealthyThresholdCount": 3,
19421953
"protocol": "TCP",
19431954
"port": "traffic-port",
1944-
"intervalSeconds": 10
1955+
"intervalSeconds": 10,
1956+
"timeoutSeconds":10
19451957
},
19461958
"targetGroupAttributes": [
19471959
{
@@ -2210,6 +2222,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
22102222
"port": "traffic-port",
22112223
"protocol": "TCP",
22122224
"intervalSeconds": 10,
2225+
"timeoutSeconds":10,
22132226
"healthyThresholdCount": 3,
22142227
"unhealthyThresholdCount": 3
22152228
},
@@ -2355,6 +2368,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
23552368
"port": "traffic-port",
23562369
"protocol": "TCP",
23572370
"intervalSeconds": 10,
2371+
"timeoutSeconds":10,
23582372
"healthyThresholdCount": 3,
23592373
"unhealthyThresholdCount": 3
23602374
},
@@ -2551,6 +2565,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
25512565
"port": "traffic-port",
25522566
"protocol": "TCP",
25532567
"intervalSeconds": 10,
2568+
"timeoutSeconds":10,
25542569
"healthyThresholdCount": 3,
25552570
"unhealthyThresholdCount": 3
25562571
},
@@ -2693,6 +2708,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
26932708
"port":"traffic-port",
26942709
"protocol":"TCP",
26952710
"intervalSeconds":10,
2711+
"timeoutSeconds":10,
26962712
"healthyThresholdCount":3,
26972713
"unhealthyThresholdCount":3
26982714
},

0 commit comments

Comments
 (0)