Repository navigation
fix(tunnel): do not log an error when the container tunnel is closed - #2
Merged
Merged
Conversation
When `devpod ssh` finishes, runInContainer cancels the container tunnel, which closes its SSH session before the remote command can send an exit status. The tunnel goroutine logged that as "Error tunneling to container: wait: remote command exited without exit status or exit signal" even though everything worked. Whether it was printed depended on the goroutine logging before the process exited. It is now logged at debug level when the tunnel's context was cancelled, and as an error otherwise. Ported from skevetter/devpod 371e52e (#586), adapted because ssh.Run here returns the session error rather than the context error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
After
devpod sshcommands that worked, this error can be printed:When
devpod sshfinishes,runInContainercancels the container tunnel. That closes the tunnel's SSH session before the remote command can send an exit status, sossh.Runreturns an error. The tunnel goroutine logged every error, this expected one included.Change
fix(tunnel): if the tunnel's context was already cancelled, the error is logged at debug level ("Container tunnel closed"); any other tunnel error is still logged as an error.Ported from skevetter/devpod 371e52e (#586). That version checked
errors.Is(err, context.Canceled), which relied on skevetter'sssh.Runreturning the context error. Heressh.Runreturns the raw session error, so the context is checked directly. The context is always cancelled before the session is closed this way, so the check doesn't depend on timing.Testing
devpod ssh --command 'echo hi'(3 of 3).mainand a matching agent, neither the unfixed nor the fixed build printed it (8 of 8 each). Debug logs showdevpod sshexits before the tunnel goroutine logs, so withmainthe error is currently hidden by timing only.go vetandgolangci-lintv1.60.1 (the version CI uses): no issues. No unit test was added;pkg/tunnelhas none, and this would need a fake SSH server for a one-condition change.🤖 Generated with Claude Code