Skip to content

Fix SshClient thread leak in EC2SSHLauncher.launchRemotingAgent()#2007

Draft
olamy wants to merge 1 commit intojenkinsci:masterfrom
olamy:ssh-client-not-cleaned-up
Draft

Fix SshClient thread leak in EC2SSHLauncher.launchRemotingAgent()#2007
olamy wants to merge 1 commit intojenkinsci:masterfrom
olamy:ssh-client-not-cleaned-up

Conversation

@olamy
Copy link
Copy Markdown
Member

@olamy olamy commented Apr 17, 2026

  • each launchRemotingAgent() creates an Apache MINA SshClient (which spawns internal thread pools nio acceptor/selectors) but only registers cleanup via a Channel.Listener callback at the end when happens of the method. If any exception occurs before computer.setChannel() is reached, the client is never cleaned up and so leaking many threads.
  • With Windows SSH agents that retry frequently during boot, this produces thousands of leaked sshd-SshClient threads.

Signed-off-by: Olivier Lamy olamy@apache.org

Testing done

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

Signed-off-by: Olivier Lamy <olamy@apache.org>
@olamy
Copy link
Copy Markdown
Member Author

olamy commented Apr 17, 2026

this is conservative option for #2008

Copy link
Copy Markdown
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable. Has this been tested in a real controller connecting to real AWS, reproducing the stated error and confirming that this addresses it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants