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

jenkins_ssh_slave doesn't work with ssh-slaves plugin 1.30.2 #726

Closed
jayhendren opened this issue Sep 24, 2019 · 3 comments
Closed

jenkins_ssh_slave doesn't work with ssh-slaves plugin 1.30.2 #726

jayhendren opened this issue Sep 24, 2019 · 3 comments

Comments

@jayhendren
Copy link

Cookbook version

7.0.0

Chef-client version

14.13.11

Platform Details

RHEL 7

Scenario:

Creating a slave using the jenkins_ssh_slave resource

Steps to Reproduce:

Install ssh-slaves plugin 1.30.2 and use jenkins_ssh_slave to create a slave.

I get no errors with ssh-slaves plugin 1.28.1. I haven't tested any intermediate versions of the plugin.

Expected Result:

Slave created without errors.

Actual Result:

* jenkins_ssh_slave[local_executor_1.example.com] action create
  
  ================================================================================
  Error executing action `create` on resource 'jenkins_ssh_slave[local_executor_1.example.com]'
  ================================================================================
  
  Mixlib::ShellOut::ShellCommandFailed
  ------------------------------------
  Expected process to exit with [0], but received '1'
  ---- Begin output of "java" -jar "/tmp/kitchen/cache/jenkins-cli.jar" -s http://localhost:8080 -"http" -user "sis-unix-jenkins" groovy = ----
  STDOUT: 
  STDERR: Sep 24, 2019 2:27:39 PM org.apache.sshd.common.util.security.AbstractSecurityProviderRegistrar getOrCreateProvider
  INFO: getOrCreateProvider(EdDSA) created instance of net.i2p.crypto.eddsa.EdDSASecurityProvider
  Sep 24, 2019 2:27:39 PM hudson.cli.CLI _main
  WARNING: -user and -auth are mutually exclusive
  Sep 24, 2019 2:27:39 PM hudson.cli.CLI _main
  WARNING: Warning: -user ignored unless using -ssh
  
  ERROR: Unexpected exception occurred while performing groovy command.
  groovy.lang.GroovyRuntimeException: Could not find matching constructor for: hudson.plugins.sshslaves.SSHLauncher(java.lang.String, java.lang.Integer, com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey, java.lang.String, null, null, null, null, null, null)
  	at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1732)
  	at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1532)
  	at org.codehaus.groovy.runtime.callsite.MetaClassConstructorSite.callConstructor(MetaClassConstructorSite.java:49)
  	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)
  	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235)
  	at RemoteClass.run(RemoteClass:64)
  	at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:263)
  	at groovy.lang.GroovyShell.run(GroovyShell.java:518)
  	at groovy.lang.GroovyShell.run(GroovyShell.java:497)
  	at hudson.cli.GroovyCommand.run(GroovyCommand.java:71)
  	at hudson.cli.CLICommand.main(CLICommand.java:251)
  	at hudson.cli.CLIAction$PlainCliEndpointResponse$1.run(CLIAction.java:218)
  	at jenkins.util.FullDuplexHttpService.download(FullDuplexHttpService.java:115)
  	at jenkins.util.FullDuplexHttpService$Response.generateResponse(FullDuplexHttpService.java:175)
  	at org.kohsuke.stapler.HttpResponseRenderer$Default.handleHttpResponse(HttpResponseRenderer.java:124)
  	at org.kohsuke.stapler.HttpResponseRenderer$Default.generateResponse(HttpResponseRenderer.java:69)
  	at org.kohsuke.stapler.Function.renderResponse(Function.java:164)
  	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:705)
  	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:878)
  	at org.kohsuke.stapler.MetaClass$9.dispatch(MetaClass.java:456)
  	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:747)
  	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:878)
  	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:676)
  	at org.kohsuke.stapler.Stapler.service(Stapler.java:238)
  	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
  	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:873)
  	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1623)
  	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:154)
  	at org.jenkinsci.plugins.ssegateway.Endpoint$SSEListenChannelFilter.doFilter(Endpoint.java:246)
  	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
  	at io.jenkins.blueocean.ResourceCacheControl.doFilter(ResourceCacheControl.java:134)
  	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
  	at io.jenkins.blueocean.auth.jwt.impl.JwtAuthenticationFilter.doFilter(JwtAuthenticationFilter.java:61)
  	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
  	at jenkins.telemetry.impl.UserLanguages$AcceptLanguageFilter.doFilter(UserLanguages.java:128)
  	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
  	at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:157)
  	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
  	at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:64)
  	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
  	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
  	at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
  	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
  	at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:117)
  	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
  	at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
  	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
  	at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
  	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
  	at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
  	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
  	at jenkins.security.BasicHeaderProcessor.success(BasicHeaderProcessor.java:140)
  	at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:82)
  	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
  	at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
  	at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67)
  	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
  	at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:90)
  	at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)
  	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
  	at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49)
  	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
  	at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82)
  	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
  	at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
  	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
  	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:540)
  	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
  	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
  	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
  	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
  	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1701)
  	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
  	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1345)
  	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
  	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:480)
  	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1668)
  	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
  	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1247)
  	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
  	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
  	at org.eclipse.jetty.server.Server.handle(Server.java:502)
  	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:370)
  	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:267)
  	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
  	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
  	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117)
  	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
  	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
  	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
  	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
  	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
  	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)
  	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683)
  	at java.lang.Thread.run(Thread.java:748)
  ---- End output of "java" -jar "/tmp/kitchen/cache/jenkins-cli.jar" -s http://localhost:8080 -"http" -user "sis-unix-jenkins" groovy = ----
  Ran "java" -jar "/tmp/kitchen/cache/jenkins-cli.jar" -s http://localhost:8080 -"http" -user "sis-unix-jenkins" groovy = returned 1
  
  Cookbook Trace:
  ---------------
  /tmp/kitchen/cache/cookbooks/jenkins/libraries/_executor.rb:86:in `execute!'
  /tmp/kitchen/cache/cookbooks/jenkins/libraries/_executor.rb:136:in `groovy!'
  /tmp/kitchen/cache/cookbooks/jenkins/libraries/slave.rb:164:in `block in do_create'
  /tmp/kitchen/cache/cookbooks/jenkins/libraries/slave.rb:163:in `do_create'
  /tmp/kitchen/cache/cookbooks/jenkins/libraries/slave.rb:150:in `block in <class:JenkinsSlave>'
  
  Resource Declaration:
  ---------------------
  # In /tmp/kitchen/cache/cookbooks/cub_policy_sis_jenkins_master/recipes/default.rb
  
   22:   jenkins_ssh_slave n['fqdn'] do
   23:     host n['fqdn']
   24:     credentials 'jenkins'
   25:     # at least 2 executors, but no more than 4 fewer than the number of cpu cores
   26:     # since 4 executors are reserved for PRs
   27:     executors num_jenkins_workers(n)
   28:     labels n['cub_policy_sis_jenkins_executor']['labels']
   29:     # stop jenkins from reaping virtualbox processes when jobs finish.
   30:     # normally, when jenkins jobs terminate, jenkins reaps backgrounds
   31:     # processes created during the job.  however, virtualbox shares these
   32:     # processes between all vms run by the same user, so reaping these
   33:     # processes kills any other testkitchen jobs that are currently running.
   34:     # see: https://wiki.jenkins-ci.org/display/JENKINS/ProcessTreeKiller
   35:     jvm_options '-Dhudson.util.ProcessTree.disable=true'
   36:   end
   37: 
  
  Compiled Resource:
  ------------------
  # Declared in /tmp/kitchen/cache/cookbooks/cub_policy_sis_jenkins_master/recipes/default.rb:22:in `block in from_file'
  
  jenkins_ssh_slave("local_executor_1.example.com") do
    action [:create]
    default_guard_interpreter :default
    declared_type :jenkins_ssh_slave
    cookbook_name "cub_policy_sis_jenkins_master"
    recipe_name "default"
    host "local_executor_1.example.com"
    credentials "jenkins"
    executors 6
    labels ["foobar", "barfoo"]
    jvm_options "-Dhudson.util.ProcessTree.disable=true"
    slave_name "local_executor_1.example.com"
  end
  
  System Info:
  ------------
  chef_version=14.13.11
  platform=redhat
  platform_version=7.7
  ruby=ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]
  program_name=/opt/chef/bin/chef-client
  executable=/opt/chef/bin/chef-client
@nanolonny
Copy link

I'm getting the same error under ssh slaves plugin 1.31.0. I downgraded to 1.28.1 reran chef job and everything is working.

@djessich
Copy link

djessich commented Nov 24, 2019

I have the same problem with version 1.31.0.

Browsing the ssh-slaves plugin source on Github (class SSHLauncher), I can confirm that since version 1.30.0 of the plugin the following Constructor (which was deprecated) has been removed. This Constructor will be used from the Groovy script of jenkins_ssh_slave resource.

@Deprecated
public SSHLauncher(String host, int port, String credentialsId, String jvmOptions, String javaPath, String prefixStartSlaveCmd, String suffixStartSlaveCmd, Integer launchTimeoutSeconds, Integer maxNumRetries, Integer retryWaitTime) { ... }

However the new Constructor since version 1.30.0 reads as follows:

public SSHLauncher(@NonNull String host, int port, String credentialsId, String jvmOptions, String javaPath, String prefixStartSlaveCmd, String suffixStartSlaveCmd, Integer launchTimeoutSeconds, Integer maxNumRetries, Integer retryWaitTime, SshHostKeyVerificationStrategy sshHostKeyVerificationStrategy) { ... }

Meaning, that jenkins_ssh_slave resource should add the SshHostKeyVerificationStrategy in its groovy script, to solve the problem.

Therefore the latest working plugin version for me is 1.29.4.

@sekberg37
Copy link

Also, you can look in #589 that issue has examples for working around this if you fork this cookbook.

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

No branches or pull requests

5 participants