Conversation
…nect coalescing Fix remaining issues from PR #37 (SSH keepalive & auto-reconnect): 1. Eliminate code duplication: ResolveConnection() now uses resolveSSHOptions() instead of duplicating SSH options construction (fixes SonarQube 3.1% > 3%) 2. Context-aware SSH Connect: Replace ssh.Dial() with net.DialContext() + ssh.NewClientConn() so context cancellation/timeout interrupts both TCP connection and SSH handshake phases 3. Reconnect coalescing: Multiple concurrent DialContext/keepalive failures trigger a single reconnect instead of racing. Lock released during retry loop to avoid blocking other DialContext callers 4. Keepalive recovery: Keepalive monitoring restarts after failed reconnect attempts, preventing permanent loss of health detection 5. In-process SSH test server: testutil_test.go provides a real SSH server (using golang.org/x/crypto/ssh) for testing connect, keepalive, tunnel forwarding, and reconnection — runs on all platforms without Docker Test coverage: internal/ssh 87.6% → 93.9%, internal/app 85.1% → 85.5% Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #38 +/- ##
==========================================
+ Coverage 80.97% 81.65% +0.68%
==========================================
Files 41 41
Lines 2901 2933 +32
==========================================
+ Hits 2349 2395 +46
+ Misses 423 410 -13
+ Partials 129 128 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Handle errcheck: use _ = for SetDeadline/Close return values in client.go - Fix goimports: remove trailing blank line in reconnect.go - Fix test auth: generate temp ed25519 key file in testutil_test.go so tests pass in CI environments without ~/.ssh keys Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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:\n- Deduplicated SSH options and improved SSH Connect to use context-aware dialer.\n- Rewrote reconnect logic to coalesce concurrent reconnects, reduce locking, and restart keepalive loops.\n- Added in-process SSH server tests and extensive reconnect/keepalive unit tests under internal/ssh.\n\nFiles changed: internal/app/conn.go, internal/ssh/client.go, internal/ssh/reconnect.go, internal/ssh/client_test.go, internal/ssh/reconnect_test.go, internal/ssh/testutil_test.go\n\nRun tests locally: go test ./... -race\n