Skip to content

fix(inject): keep exact milliseconds in proxy timeout annotations - #15736

Open
RaphaelFakhri wants to merge 1 commit into
linkerd:mainfrom
RaphaelFakhri:fix/inject-timeout-ms-rounding
Open

RaphaelFakhri wants to merge 1 commit into
linkerd:mainfrom
RaphaelFakhri:fix/inject-timeout-ms-rounding

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

The proxy-outbound-connect-timeout, proxy-inbound-connect-timeout and shutdown-grace-period annotations are converted to milliseconds with int(duration.Seconds()*1000). Many durations are not exactly representable as float64 seconds, so the truncation drops a millisecond: 1001ms becomes 1000ms, 2.47s becomes 2469ms and 4060ms becomes 4059ms.

Use duration.Milliseconds(), which does integer arithmetic on the nanosecond count.

Validation:

  • Added a TestGetOverriddenValues case with the three values above. It fails before the change (1000ms != 1001ms, 2469ms != 2470ms, 4059ms != 4060ms) and passes after it.
  • go test ./pkg/inject/ ./cli/cmd/ ./controller/webhook/... ./controller/proxy-injector/... passes.
  • gofmt -l and go vet ./pkg/inject/ report nothing.

Fixes #15735

Signed-off-by: Raphael Fakhri 153192858+RaphaelFakhri@users.noreply.github.com

The proxy-outbound-connect-timeout, proxy-inbound-connect-timeout and
shutdown-grace-period annotations are converted to milliseconds with
int(duration.Seconds()*1000). Many durations are not exactly
representable as float64 seconds, so the truncation drops a millisecond:
1001ms becomes 1000ms, 2.47s becomes 2469ms and 4060ms becomes 4059ms.

Use duration.Milliseconds(), which does integer arithmetic on the
nanosecond count.

Add a TestGetOverriddenValues case that fails before the change and
passes after it.

Signed-off-by: Raphael Fakhri <153192858+RaphaelFakhri@users.noreply.github.com>
@RaphaelFakhri
RaphaelFakhri requested a review from a team as a code owner October 20, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proxy timeout annotations lose a millisecond for some values

1 participant