Fix SSH agent forwarding for long-running sessions#74
Merged
Conversation
Add retry with exponential backoff on agent socket dial (handles transient gcr-ssh-agent restarts), SSH keepalive to detect dead connections, and warn-level logging for agent failures that were previously invisible at debug level. Inject SSHAuthSock via SessionOpts instead of reading os.Getenv in infrastructure layer. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Picks up the SSH agent forwarding half-close fix (go-microvm#49) that prevents goroutine leaks exhausting the agent connection semaphore during long-running sessions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
macOS limits Unix socket paths to 104 bytes. t.TempDir() combined with long test names exceeded this limit causing bind failures. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Force --no-ff on git merge to ensure a merge commit is always created regardless of git config or platform defaults. Co-Authored-By: Claude Opus 4.6 (1M context) <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.
Summary
channel.CloseWrite()in the guest SSH server's agent proxy caused goroutine leaks that exhausted themaxAgentConnssemaphore after ~8 agent connections, breaking SSH agent forwarding for the rest of the session. Symptom: git operations succeed for the first few minutes then fail withPermission denied (publickey).keepalive@openssh.comrequests to detect dead mux connections early and prevent idle timeouts.gcr-ssh-agent).SSHAuthSockviaSessionOpts— replacesos.Getenv("SSH_AUTH_SOCK")in the infrastructure layer with dependency injection through the domain layer, improving testability and DDD compliance.Test plan
TestDialAgentWithRetry_{SuccessFirstAttempt,AllRetriesFail,SuccessAfterRetry,ContextCancelled},TestSetupAgentForwarding_{EmptyAuthSock,UnreachableSocket}task test— full suite passes with race detectortask lint— zero issuesgit fetchloop every 2 minutes — 8/8 succeeded (was 2/8 before fix)🤖 Generated with Claude Code