Migrate kubectl exec to WebSockets from SPDY#758
Conversation
Per [KEP-4006](https://github.com/kubernetes/enhancements/tree/master/keps/sig-api-machinery/4006-transition-spdy-to-websockets), prioritize trying WebSockets first given it has been the default for 4 versions now and will be the standard going forward. Use a NewFallbackExecutor as is suggested in the KEP to avoid breaking existing use cases.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughClient.Exec now attempts a WebSocket-based Kubernetes exec first and constructs an SPDY executor as a fallback, wrapped with remotecommand.NewFallbackExecutor that uses httpstream.IsUpgradeFailure and httpstream.IsHTTPSProxyError to decide when to fall back. ChangesKubernetes WebSocket Executor Fallback
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/driver/kubernetes/client.go`:
- Line 128: The fallback predicate passed to remotecommand.NewFallbackExecutor
currently only uses httpstream.IsUpgradeFailure; update the call in the
remotecommand.NewFallbackExecutor invocation (the websocketExec, spdyExec
creation site) to use a combined predicate that checks both
httpstream.IsUpgradeFailure and httpstream.IsHTTPSProxyError (i.e., call
NewFallbackExecutor with a predicate that returns true if either
IsUpgradeFailure or IsHTTPSProxyError matches) so HTTPS-proxy dial failures will
trigger the SPDY fallback just like kubectl.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 635de3ff-cde9-4e2d-a7ba-7614d78d4fa7
📒 Files selected for processing (1)
pkg/driver/kubernetes/client.go
pick up the same additional error handling that was introduced by this commit to the kubectl client. kubernetes/kubectl@2c588bc Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
|
Happy to get this merged in once the failing jobs are fixed. |
( clone of PR loft-sh#1980 )
I've added websocket support since I want to setup a capsule kube api proxy which was dropping connections due to lack of SPDY support.
Per KEP-4006, I prioritize trying WebSockets first given Websockets have been the default for 4 versions now and will be the standard going forward. I used
NewFallbackExecutoras suggested in the KEP to avoid breaking existing use cases.This follows the implementation used by kubectl: https://github.com/kubernetes/kubectl/blob/8144b746a47f142759a073a46f581de92b1886aa/pkg/cmd/exec/exec.go#L146-L166
I've built this locally and have been using it successfully for myself and a few others. Disclosure: this fix was found with the assistance of claude/copilot.
Summary by CodeRabbit