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

Edit tasklist title
Beta Give feedback Tasklist Maintainer checklist, more options

Delete tasklist

Delete tasklist block?
Are you sure? All relationships in this tasklist will be removed.
  1. There are at least two (2) approvals for the pull request and no outstanding requests for change.
    Options
  2. Conversations in the pull request are over, or it is explicit that a reviewer is not blocking the change.
    Options
  3. Changelog entries in the pull request title and/or Proposed changelog entries are accurate, human-readable, and in the imperative mood.
    Options
  4. Proper changelog labels are set so that the changelog can be generated automatically.
    Options
  5. If the change needs additional upgrade steps from users, the upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the pull request title (see example).
    Options
  6. If it would make sense to backport the change to LTS, a Jira issue must exist, be a Bug or Improvement, and be labeled as lts-candidate to be considered (see query).
    Options

@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
3 participants