Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log Errors from SlaveComputer._connect #8675

Merged
merged 1 commit into from
Nov 5, 2023

Conversation

jglick
Copy link
Member

@jglick jglick commented Nov 3, 2023

When an (outbound) agent fails to launch, we expect any errors to be printed to the agent log. This is done by _connect, since (unlike the case in #7284) this returns a Future and a caller of Computer.connect may or may wait for it (get; most do not). While this checked for a variety of checked and unchecked exceptions, it failed to account for Errors.

Testing done

Discovered while investigating a (proprietary) test flake. Without the patch, when launching fails (randomly), nothing appears in the log; in fact slave.log is not created at all. With the patch, the agent log shows the error, in this case

ERROR: Unexpected error in launching an agent. This is probably a bug in Jenkins
java.lang.ClassNotFoundException: org.bouncycastle.crypto.prng.RandomGenerator
	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:476)
	at jenkins.util.URLClassLoader2.findClass(URLClassLoader2.java:35)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:594)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:527)
Also:   java.lang.Throwable: launched here
	at hudson.slaves.SlaveComputer._connect(SlaveComputer.java:286)
	at hudson.model.Computer.connect(Computer.java:448)
	at …
Caused: java.lang.NoClassDefFoundError: org/bouncycastle/crypto/prng/RandomGenerator
	at org.apache.sshd.common.util.security.bouncycastle.BouncyCastleRandomFactory.create(BouncyCastleRandomFactory.java:43)
	at org.apache.sshd.common.util.security.bouncycastle.BouncyCastleRandomFactory.create(BouncyCastleRandomFactory.java:28)
	at org.apache.sshd.common.random.SingletonRandomFactory.<init>(SingletonRandomFactory.java:38)
	at org.apache.sshd.common.BaseBuilder.fillWithDefaultValues(BaseBuilder.java:166)
	at org.apache.sshd.client.ClientBuilder.fillWithDefaultValues(ClientBuilder.java:110)
	at org.apache.sshd.client.ClientBuilder.fillWithDefaultValues(ClientBuilder.java:54)
	at org.apache.sshd.common.BaseBuilder.build(BaseBuilder.java:273)
	at org.apache.sshd.client.ClientBuilder.build(ClientBuilder.java:161)
	at com.cloudbees.jenkins.plugins.sshslaves.PluginImpl.sshClient(PluginImpl.java:23)
	at com.cloudbees.jenkins.plugins.sshslaves.SSHLauncher.openConnection(SSHLauncher.java:326)
	at com.cloudbees.jenkins.plugins.sshslaves.SSHLauncher.launch(SSHLauncher.java:153)
	at hudson.slaves.SlaveComputer.lambda$_connect$0(SlaveComputer.java:297)
	at …

(Never mind the root cause for purposes of this PR.)

Proposed changelog entries

  • More consistently report errors launching outbound agents.

Proposed upgrade guidelines

N/A

Before the changes are marked as ready-for-merge:

Maintainer checklist

@NotMyFault NotMyFault added the rfe For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted label Nov 4, 2023
Copy link
Member

@NotMyFault NotMyFault left a comment

Choose a reason for hiding this comment

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

/label ready-for-merge


This PR is now ready for merge. We will merge it after ~24 hours if there is no negative feedback.
Please see the merge process documentation for more information about the merge process.
Thanks!

@comment-ops-bot comment-ops-bot bot added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Nov 4, 2023
@NotMyFault NotMyFault merged commit d06f360 into jenkinsci:master Nov 5, 2023
16 checks passed
@jglick jglick deleted the SlaveComputer._connect branch November 6, 2023 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback rfe For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants