Skip to content

Commit 4f879fc

Browse files
committed
fix: preserve subsecond healthCheckFailureDelay values
Formatting the delay with %.0f rounded subsecond durations such as 400ms down to 0s, silently discarding the configured delay. Use the duration's own string form instead, which the shutdown manager parses with time.ParseDuration.
1 parent 89d8e2e commit 4f879fc

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

internal/infrastructure/kubernetes/proxy/resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ func expectedShutdownPreStopCommand(cfg *egv1a1.ShutdownConfig) []string {
289289
if err != nil {
290290
return nil
291291
}
292-
command = append(command, fmt.Sprintf("--health-check-failure-delay=%.0fs", d.Seconds()))
292+
command = append(command, fmt.Sprintf("--health-check-failure-delay=%s", d.String()))
293293
}
294294

295295
if cfg.DrainTimeout != nil {

internal/infrastructure/kubernetes/proxy/resource_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,18 @@ func TestExpectedShutdownPreStopCommand(t *testing.T) {
211211
"--min-drain-duration=5s",
212212
},
213213
},
214+
{
215+
name: "subsecond health check failure delay",
216+
cfg: &egv1a1.ShutdownConfig{
217+
HealthCheckFailureDelay: new(gwapiv1.Duration("400ms")),
218+
},
219+
expected: []string{
220+
"envoy-gateway",
221+
"envoy",
222+
"shutdown",
223+
"--health-check-failure-delay=400ms",
224+
},
225+
},
214226
}
215227

216228
for _, tt := range tests {

0 commit comments

Comments
 (0)