fix(exec): pass -i to cocoon vm exec only when the caller attaches stdin#31
Merged
Conversation
cocoon v0.5.0 made vm exec stdin opt-in (docker semantics): without -i the child's stdin closes immediately. vk wired kubectl's stdin stream to the cocoon process unconditionally, so on v0.5.0+ hosts 'kubectl exec -i' delivers EOF instead of the caller's input. Map attach.Stdin() presence to -i: RunInContainer gets a nil reader when kubectl exec runs without -i, so stdin-less execs (including post-clone) keep their exact argv and no longer wire an unused pipe. Requires cocoon >= v0.5.0 for interactive execs (older cocoon rejects -i as an unknown flag); non-interactive execs are unaffected either way.
The -i opt-in landed in cocoon v0.4.8, not v0.5.0, and the note that stdin-less execs skip -i does not hold on the websocket exec path (its ignore-channel hands back a non-nil stdin reader), so the argv still carries -i there — harmless on cocoon >= v0.4.8. Describe what the code does instead of overstating the version/stream guarantees.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
cocoon v0.5.0 made
vm execstdin opt-in (docker semantics, cocoonstack/cocoon#119 area, commit 05dbae9): without-ithe child's stdin closes immediately. vk builds the exec argv without-iwhile unconditionally wiring kubectl's stdin stream to the cocoon subprocess — so on hosts running cocoon >= v0.5.0,kubectl exec -i(and-it) silently delivers EOF to the guest command instead of the caller's input.Fix
Map
attach.Stdin()presence to-i:RunInContainerreceives a nil stdin reader exactly when kubectl exec runs without-i, sostdin != nilis the interactive signal.-iprepended and the stream wired as before.exec.Cmdnil Stdin = /dev/null, matching the new cocoon semantics).Compatibility / rollout
-ias an unknown flag) — upgrade the cocoon binary before rolling this vk out. Note today's vk on cocoon v0.5.0 has interactive exec broken anyway, so ordering cocoon-first loses nothing.Testing
go build ./... && go test ./... && go vet ./...clean.TestBuildExecArgsAssemblesEnvAndArgvpinning-iplacement before-e.