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

Error when running a slave with credentials #96

Open
marksmithson opened this issue Apr 15, 2020 · 6 comments · May be fixed by #104
Open

Error when running a slave with credentials #96

marksmithson opened this issue Apr 15, 2020 · 6 comments · May be fixed by #104

Comments

@marksmithson
Copy link

The error at the bottom of this issue is reported when running a job on a jenkins slave which uses the AWSEB plugin.

Looking at the diff from 0.3.19 to 0.3.20 it looks like the change in src/main/java/br/com/ingenieux/jenkins/plugins/awsebdeployment/AWSClientFactory.java from using Jenkins.getInstance() to Jenkins.get() due to deprecation may be the issue.

Looking at https://javadoc.jenkins-ci.org/jenkins/model/Jenkins.html#getInstance--, I think this should be using Jenkins.getInstanceOrNull() for this use case?

AWSEB Deployment Plugin Version 0.3.20 (aws-java-sdk version: 1.11.723) FATAL: Deployment Failure Also: hudson.remoting.Channel$CallSiteStackTrace: Remote call to EC2 (Jenkins EC2 slaves) - linux ubuntu16 large (i-xxxxxxxxxxxx) at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1788) at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356) at hudson.remoting.Channel$2.adapt(Channel.java:1033) at hudson.remoting.Channel$2.adapt(Channel.java:1029) at hudson.remoting.FutureAdapter.get(FutureAdapter.java:55) at br.com.ingenieux.jenkins.plugins.awsebdeployment.DeployerRunner.perform(DeployerRunner.java:64) at br.com.ingenieux.jenkins.plugins.awsebdeployment.AWSEBDeploymentBuilder.perform(AWSEBDeploymentBuilder.java:243) at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:78) at br.com.ingenieux.jenkins.plugins.awsebdeployment.AWSEBDeploymentBuilder.perform(AWSEBDeploymentBuilder.java:79) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741) at hudson.model.Build$BuildExecution.build(Build.java:206) at hudson.model.Build$BuildExecution.doRun(Build.java:163) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504) at hudson.model.Run.execute(Run.java:1856) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:428) java.lang.IllegalStateException: Jenkins.instance is missing. Read the documentation of Jenkins.getInstanceOrNull to see what you are doing wrong. at jenkins.model.Jenkins.get(Jenkins.java:779) at br.com.ingenieux.jenkins.plugins.awsebdeployment.AWSClientFactory.lookupNamedCredential(AWSClientFactory.java:95) at br.com.ingenieux.jenkins.plugins.awsebdeployment.AWSClientFactory.getClientFactory(AWSClientFactory.java:85) at br.com.ingenieux.jenkins.plugins.awsebdeployment.cmd.DeployerCommand$InitAWS.perform(DeployerCommand.java:143) at br.com.ingenieux.jenkins.plugins.awsebdeployment.cmd.DeployerChain.perform(DeployerChain.java:54) at br.com.ingenieux.jenkins.plugins.awsebdeployment.SlaveDeployerCallable.call(SlaveDeployerCallable.java:42) at br.com.ingenieux.jenkins.plugins.awsebdeployment.SlaveDeployerCallable.call(SlaveDeployerCallable.java:27) at hudson.remoting.UserRequest.perform(UserRequest.java:211) at hudson.remoting.UserRequest.perform(UserRequest.java:54) at hudson.remoting.Request$2.run(Request.java:369) at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused: java.util.concurrent.ExecutionException at hudson.remoting.Channel$2.adapt(Channel.java:1035) at hudson.remoting.Channel$2.adapt(Channel.java:1029) at hudson.remoting.FutureAdapter.get(FutureAdapter.java:55) at br.com.ingenieux.jenkins.plugins.awsebdeployment.DeployerRunner.perform(DeployerRunner.java:64) at br.com.ingenieux.jenkins.plugins.awsebdeployment.AWSEBDeploymentBuilder.perform(AWSEBDeploymentBuilder.java:243) Caused: java.io.IOException: Deployment Failure at br.com.ingenieux.jenkins.plugins.awsebdeployment.AWSEBDeploymentBuilder.perform(AWSEBDeploymentBuilder.java:245) at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:78) at br.com.ingenieux.jenkins.plugins.awsebdeployment.AWSEBDeploymentBuilder.perform(AWSEBDeploymentBuilder.java:79) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741) at hudson.model.Build$BuildExecution.build(Build.java:206) at hudson.model.Build$BuildExecution.doRun(Build.java:163) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504) at hudson.model.Run.execute(Run.java:1856) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:428)

@DraconPern
Copy link

Ditto, I ran into this issue after fixing missing settings after an update.

@DraconPern
Copy link

for anyone else with this issue. my fix for now was to run it on master.

@mpaluchowski
Copy link

I think we have the same issue after upgrading to 0.3.20 or 0.3.21. 0.3.19 works fine, and we're staying on it, despite the XSS vulnerability. We're running builds on slave nodes. Here's our error:

Also:   hudson.remoting.Channel$CallSiteStackTrace: Remote call to EC2 (Jenkins Build Farm) - default (i-069e4d01f801c3d3d)
		at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1788)
		at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
		at hudson.remoting.Channel$2.adapt(Channel.java:1033)
		at hudson.remoting.Channel$2.adapt(Channel.java:1029)
		at hudson.remoting.FutureAdapter.get(FutureAdapter.java:55)
		at br.com.ingenieux.jenkins.plugins.awsebdeployment.DeployerRunner.perform(DeployerRunner.java:64)
		at br.com.ingenieux.jenkins.plugins.awsebdeployment.AWSEBDeploymentBuilder.perform(AWSEBDeploymentBuilder.java:243)
		at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:80)
		at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:67)
		at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
		at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
java.lang.RuntimeException: Missing Jenkins Instance
	at br.com.ingenieux.jenkins.plugins.awsebdeployment.AWSClientFactory.lookupNamedCredential(AWSClientFactory.java:96)
	at br.com.ingenieux.jenkins.plugins.awsebdeployment.AWSClientFactory.getClientFactory(AWSClientFactory.java:85)
	at br.com.ingenieux.jenkins.plugins.awsebdeployment.cmd.DeployerCommand$InitAWS.perform(DeployerCommand.java:143)
	at br.com.ingenieux.jenkins.plugins.awsebdeployment.cmd.DeployerChain.perform(DeployerChain.java:54)
	at br.com.ingenieux.jenkins.plugins.awsebdeployment.SlaveDeployerCallable.call(SlaveDeployerCallable.java:42)
	at br.com.ingenieux.jenkins.plugins.awsebdeployment.SlaveDeployerCallable.call(SlaveDeployerCallable.java:27)
	at hudson.remoting.UserRequest.perform(UserRequest.java:211)
	at hudson.remoting.UserRequest.perform(UserRequest.java:54)
	at hudson.remoting.Request$2.run(Request.java:369)
	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
Caused: java.util.concurrent.ExecutionException
	at hudson.remoting.Channel$2.adapt(Channel.java:1035)
	at hudson.remoting.Channel$2.adapt(Channel.java:1029)
	at hudson.remoting.FutureAdapter.get(FutureAdapter.java:55)
	at br.com.ingenieux.jenkins.plugins.awsebdeployment.DeployerRunner.perform(DeployerRunner.java:64)
	at br.com.ingenieux.jenkins.plugins.awsebdeployment.AWSEBDeploymentBuilder.perform(AWSEBDeploymentBuilder.java:243)
Caused: java.io.IOException: Deployment Failure
	at br.com.ingenieux.jenkins.plugins.awsebdeployment.AWSEBDeploymentBuilder.perform(AWSEBDeploymentBuilder.java:245)
	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:80)
	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:67)
	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

@JustinPihony
Copy link

JustinPihony commented Sep 8, 2020

For those looking how to implement the workaround: https://stackoverflow.com/a/40757312/779513 Although, it did not work for me for some reason, so I ended up rolling back until this is resolved.

@nam-truong-le
Copy link

nam-truong-le commented Apr 21, 2021

These two lines return error if executed in Agent:

The plugin shouldn't rely on the jenkins instance. Please refer to: https://javadoc.jenkins-ci.org/jenkins/model/Jenkins.html

In other cases you may have code that might end up running on a remote JVM and not on the Jenkins master. For those cases you really should rewrite your code so that when the Callable is sent over the remoting channel it can do whatever it needs without ever referring to Jenkins; for example, gather any information you need on the master side before constructing the callable. If you must do a runtime check whether you are in the master or agent, use JenkinsJVM rather than this method, as merely loading the Jenkins class file into an agent JVM can cause linkage errors under some conditions.

@aldrinleal
Copy link
Member

The plugin shouldn't rely on the jenkins instance. Please refer to: https://javadoc.jenkins-ci.org/jenkins/model/Jenkins.html

In other cases you may have code that might end up running on a remote JVM and not on the Jenkins master. For those cases you really should rewrite your code so that when the Callable is sent over the remoting channel it can do whatever it needs without ever referring to Jenkins; for example, gather any information you need on the master side before constructing the callable. If you must do a runtime check whether you are in the master or agent, use JenkinsJVM rather than this method, as merely loading the Jenkins class file into an agent JVM can cause linkage errors under some conditions.

Can you perhaps come up with a PR?

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 a pull request may close this issue.

6 participants