fix: Ensure SSH connections are closed after each command execution #859
+2
−0
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.
This commit addresses an issue where SSH connections were not being properly closed after each command execution, leading to timeout errors during the
kamal deploy
process.Problem
When executing commands using the
execute
method inSSHKit::Runner::Parallel
, SSH connections were left open, causing subsequent commands to fail with timeout errors. This issue was particularly evident when runningkamal build deliver
afterkamal registry login
during the normalkamal deploy process
Solution
The
execute
method in theSSHKit::Runner::Parallel::CompleteAll
module has been modified to ensure that all SSH connections are closed after each command execution. This is achieved by adding anensure
block to the thread creation logic, which callsSSHKit::Backend::Netssh.pool.close_connections
after each command, regardless of whether an exception occurs.Changes
ensure
block to theexecute
method inSSHKit::Runner::Parallel::CompleteAll
to close SSH connections after each command execution.Impact
This change ensures that SSH connections are properly closed, preventing timeout errors and improving the reliability of the
kamal deploy
process.Testing
Tested the changes by running
kamal deploy
commands. Verified that the timeout errors no longer occur and the deployment process completes successfully.Closes #857