Migrate kubectl exec to WebSockets from SPDY#758
Conversation
|
Warning Review limit reached
More reviews will be available in 21 minutes and 45 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ 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, constructs an SPDY executor in parallel, and wraps both with remotecommand.NewFallbackExecutor that falls back when httpstream.IsUpgradeFailure reports an upgrade failure. ChangesKubernetes WebSocket Executor Fallback
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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
|
Happy to get this merged in once the failing jobs are fixed. |
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. Signed-off-by: andyvandy <vandenhoeven.andrew@gmail.com>
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>
signed the commit to address the failure. Not a huge deal but fyi the 1password check which is meant to comment with instructions was failing with a 403 error "message": "Resource not accessible by integration" |
That job can be flaky sometimes; It should be working now. |
( 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