Skip to content

Set IdleTimeout on the supervisor http server - #14904

Merged
brandond merged 2 commits into
k3s-io:mainfrom
somaz94:fix/14901-supervisor-idle-timeout
Oct 28, 2026
Merged

brandond merged 2 commits into
k3s-io:mainfrom
somaz94:fix/14901-supervisor-idle-timeout

Conversation

@somaz94

@somaz94 somaz94 commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Proposed Changes

The supervisor http.Server on 6443 sets no IdleTimeout, so net/http never closes an idle keep-alive connection, for HTTP/1.1 or HTTP/2. A client that goes away without the server seeing a FIN leaves the connection and its goroutines on the server until restart. This sets IdleTimeout to 90 seconds, the value kube-apiserver uses on its own secure serving http.Server. Because the listener negotiates h2 and the server is left to configure HTTP/2 itself, the same field also applies to HTTP/2 connections.

Types of Changes

Bugfix

Verification

With the dynamiclistener TLS listener and the same NextProtos as newListener, a connection that has served one request and then sits idle stays open indefinitely with IdleTimeout unset, on both http/1.1 and h2. With IdleTimeout set, the server closes it once the timeout passes. A response that keeps streaming for longer than the timeout (the shape of a watch) is not cut off on either protocol, since the idle timeout only applies between requests. The reproduction in #14901 (one keep-alive request to 6443 and 6444, then wait) should now show 6443 closing after about 90 seconds, like 6444.

Testing

No unit test added: the change is one field on the server struct, and a test that waits out a real 90 second timeout or only asserts the field value would not add much. go test ./pkg/cluster/ passes on linux/arm64 with Go 1.26, and go vet and golangci-lint on pkg/cluster report nothing new.

Linked Issues

#14901

User-Facing Change

The supervisor now closes idle client connections after 90 seconds, matching kube-apiserver.

Further Comments

I used Claude Code to help prepare this change and checked the result myself, including the verification above.

somaz94 added a commit to somaz94/somaz94 that referenced this pull request Oct 26, 2026
@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.29%. Comparing base (65d7127) to head (295bef6).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14904      +/-   ##
==========================================
- Coverage   52.14%   49.29%   -2.85%     
==========================================
  Files         197      197              
  Lines       16013    16013              
==========================================
- Hits         8350     7894     -456     
- Misses       6357     6906     +549     
+ Partials     1306     1213      -93     
Flag Coverage Δ
e2etests 41.46% <ø> (-0.28%) ⬇️
inttests 3.21% <ø> (-36.71%) ⬇️
unittests 27.33% <ø> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@brandond

Copy link
Copy Markdown
Member

Any particular reason this is still in draft?

Comment thread pkg/cluster/https.go Resolved
Signed-off-by: Brad Davidson <[email protected]>
@brandond
brandond marked this pull request as ready for review October 28, 2026 00:17
@brandond
brandond requested a review from a team as a code owner October 28, 2026 00:17
Comment thread pkg/cluster/https.go
Comment on lines +125 to +128
// Same values as kubernetes apiserver
MaxHeaderBytes: 1 << 20,
IdleTimeout: 90 * time.Second,
ReadHeaderTimeout: 32 * time.Second,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will also note that (unlike upstream) we are not serving with http/2 on this port. Maybe someday we might want to do that.

@brandond

Copy link
Copy Markdown
Member

tests flaked due to #14915 - merging

@brandond
brandond merged commit 1bebce8 into k3s-io:main Oct 28, 2026
112 of 118 checks passed
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.

3 participants