fix(ssh): remove unreachable code in connectOrDie, wrap last error#655
Merged
ArangoGutierrez merged 1 commit intoNVIDIA:mainfrom Feb 13, 2026
Merged
Conversation
After the retry loop, connectionFailed is always true, making the final return statement unreachable. Simplify to unconditionally return the error after the loop. Also wrap the last dial error with %w so callers see the root cause (e.g. 'connection refused'). Audit findings NVIDIA#5 (HIGH), NVIDIA#6 (HIGH), NVIDIA#27 (LOW). Signed-off-by: Carlos Eduardo Arango Gutierrez <eduardoa@nvidia.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes unreachable code and improves error handling in two connectOrDie functions that establish SSH connections with retry logic. The changes address three audit findings (#5, #6, and #27) by removing dead code that was never executed after retry loops and wrapping the final error with %w to enable proper error chain inspection.
Changes:
- Removed dead code (unreachable
connectionFailedflag and return statements) after retry loops - Updated error formatting to wrap the last error with
%winstead of discarding it - Improved code clarity by eliminating unnecessary boolean flag logic
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/provisioner/provisioner.go | Simplified connectOrDie retry loop by removing dead code and wrapping the last SSH dial error with %w |
| cmd/cli/dryrun/dryrun.go | Simplified connectOrDie retry loop by removing dead code, introducing explicit lastErr tracking, and wrapping the error with %w |
Pull Request Test Coverage Report for Build 21963044306Details
💛 - Coveralls |
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
%wso callers can inspect the root causeAudit Findings
Changes
pkg/provisioner/provisioner.go: Simplify connectOrDie retry loopcmd/cli/dryrun/dryrun.go: Simplify connectOrDie retry loop + wrap errorTest plan
gofmt— no formatting issuesgo build— compilesgo test ./pkg/...— all tests pass