[JIRA] (JENKINS-56684) Config as Code Nullpointer when instanceCapStr is not initialized

9 views
Skip to first unread message

Jake.Remitz@carlsonwagonlit.com (JIRA)

unread,
Mar 22, 2019, 11:18:02 AM3/22/19
to jenkinsc...@googlegroups.com
Jake Remitz created an issue
 
Jenkins / Bug JENKINS-56684
Config as Code Nullpointer when instanceCapStr is not initialized
Issue Type: Bug Bug
Assignee: FABRIZIO MANFREDI
Components: ec2-plugin
Created: 2019-03-22 15:17
Labels: ec2-plugin
Priority: Minor Minor
Reporter: Jake Remitz

A Nullpointer is returned trying to reload updated configuration when the EC2 plugin is configured without the instanceCapStr included. 

Nullpointer:

java.lang.NullPointerException
	at hudson.plugins.ec2.EC2Cloud.<init>(EC2Cloud.java:183)
	at hudson.plugins.ec2.AmazonEC2Cloud.<init>(AmazonEC2Cloud.java:72)
Caused: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:141)
Caused: io.jenkins.plugins.casc.ConfiguratorException: amazonEC2: Failed to construct instance of class hudson.plugins.ec2.AmazonEC2Cloud.
 Constructor: public hudson.plugins.ec2.AmazonEC2Cloud(java.lang.String,boolean,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.util.List,java.lang.String,java.lang.String).
 Arguments: [java.lang.String, java.lang.Boolean, java.lang.String, java.lang.String, java.lang.String, null, null, null, null]
	at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:149) 

Minimum example to reproduce via Config as Code:

jenkins:
  clouds:
  - amazonEC2:
      cloudName: "TestCloud"
      #instanceCapStr: ""
      privateKey: ""
      region: "us-west-2"
      useInstanceProfileForCredentials: false

 

I believe that we just need a null check here: [https://github.com/jenkinsci/ec2-plugin
/blob/7aae12427c40c15a020ca445cffe6c812113ecce/src/main/java/hudson/plugins/ec2/EC2Cloud.java#L185] or instanceCapStr.isEmpty()

Might want to update the demo example as well. It may be helpful, related to the recently closed Windows EC2 Slave issue, to include an example with user_data.  That's unrelated to this request though.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

Jake.Remitz@carlsonwagonlit.com (JIRA)

unread,
Mar 22, 2019, 11:20:02 AM3/22/19
to jenkinsc...@googlegroups.com
Jake Remitz updated an issue
Change By: Jake Remitz
A Nullpointer is returned trying to reload updated configuration when the EC2 plugin is configured without the instanceCapStr included. 

Nullpointer:
{code:java}

java.lang.NullPointerException
at hudson.plugins.ec2.EC2Cloud.<init>(EC2Cloud.java:183)
at hudson.plugins.ec2.AmazonEC2Cloud.<init>(AmazonEC2Cloud.java:72)
Caused: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:141)
Caused: io.jenkins.plugins.casc.ConfiguratorException: amazonEC2: Failed to construct instance of class hudson.plugins.ec2.AmazonEC2Cloud.
Constructor: public hudson.plugins.ec2.AmazonEC2Cloud(java.lang.String,boolean,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.util.List,java.lang.String,java.lang.String).
Arguments: [java.lang.String, java.lang.Boolean, java.lang.String, java.lang.String, java.lang.String, null, null, null, null]
at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:149) {code}

Minimum example to reproduce via Config as Code:
{code:java}

jenkins:
  clouds:
  - amazonEC2:
      cloudName: "TestCloud"
      #instanceCapStr: ""
      privateKey: ""
      region: "us-west-2"
      useInstanceProfileForCredentials: false
{code}

 

I believe that we just need a null check here: [https://github.com/jenkinsci/ec2-plugin
/blob/7aae12427c40c15a020ca445cffe6c812113ecce/src/main/java/hudson/plugins/ec2/EC2Cloud.java#L185] or instanceCapStr.isEmpty()

Might want to update the demo example as well if it helps clarify for any required fields . It may be helpful, related to the recently closed Windows EC2 Slave issue, to include an example of a Windows slave with user_data.  That's unrelated to this request though.

Jake.Remitz@carlsonwagonlit.com (JIRA)

unread,
Mar 22, 2019, 11:21:02 AM3/22/19
to jenkinsc...@googlegroups.com
Jake Remitz updated an issue
A Nullpointer is returned trying to reload updated configuration when the EC2 plugin is configured without the instanceCapStr included. 

Nullpointer:
{code:java}
java.lang.NullPointerException
at hudson.plugins.ec2.EC2Cloud.<init>(EC2Cloud.java:183)
at hudson.plugins.ec2.AmazonEC2Cloud.<init>(AmazonEC2Cloud.java:72)
Caused: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:141)
Caused: io.jenkins.plugins.casc.ConfiguratorException: amazonEC2: Failed to construct instance of class hudson.plugins.ec2.AmazonEC2Cloud.
Constructor: public hudson.plugins.ec2.AmazonEC2Cloud(java.lang.String,boolean,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.util.List,java.lang.String,java.lang.String).
Arguments: [java.lang.String, java.lang.Boolean, java.lang.String, java.lang.String, java.lang.String, null, null, null, null]
at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:149) {code}
Minimum example to reproduce via Config as Code (uncomment the instanceCapStr and it will reload successfully) :

{code:java}
jenkins:
  clouds:
  - amazonEC2:
      cloudName: "TestCloud"
      #instanceCapStr: ""
      privateKey: ""
      region: "us-west-2"
      useInstanceProfileForCredentials: false
{code}
 

I believe that we just need a null check here: [https://github.com/jenkinsci/ec2-plugin
/blob/7aae12427c40c15a020ca445cffe6c812113ecce/src/main/java/hudson/plugins/ec2/EC2Cloud.java#L185] or instanceCapStr.isEmpty()

Might want to update the demo example as well if it helps clarify for any required fields. It may be helpful, related to the recently closed Windows EC2 Slave issue, to include an example of a Windows slave with user_data.  That's unrelated to this request though.

Jake.Remitz@carlsonwagonlit.com (JIRA)

unread,
Mar 29, 2019, 2:12:02 AM3/29/19
to jenkinsc...@googlegroups.com
      remoteFS: "c:\\jenkins"
      useInstanceProfileForCredentials: false
{code}
 

I believe that we just need a null check here: [https://github.com/jenkinsci/ec2-plugin
/blob/7aae12427c40c15a020ca445cffe6c812113ecce/src/main/java/hudson/plugins/ec2/EC2Cloud.java#L185] or instanceCapStr.isEmpty()

Might want to update the demo example as well if it helps clarify for any required fields. It may be helpful, related to the recently closed Windows EC2 Slave issue, to include an example of a Windows slave with user_data.  That's unrelated to this request though.


 

*EDIT*: I've just noticed that I'm also getting a nullpointer when I do not specify the {{remoteFS: "c:\\jenkins"}} via CasC as well.  I've updated the above example to include it.  I received the following exception:
{code:java}
java.lang.NullPointerException
at hudson.Util.isRelativePath(Util.java:557)
at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:642)
at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:432)
at hudson.plugins.ec2.win.EC2WindowsLauncher.launchScript(EC2WindowsLauncher.java:76)
at hudson.plugins.ec2.EC2ComputerLauncher.launch(EC2ComputerLauncher.java:48)
at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:294)
at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71)
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){code}

Jake.Remitz@carlsonwagonlit.com (JIRA)

unread,
Mar 29, 2019, 2:14:02 AM3/29/19
to jenkinsc...@googlegroups.com
}}
{{
jenkins"}} via CasC as well.  I've updated the above example to include it.  I received the following exception right after winrm connects and the temp directory is created if it doesn't exist :

{code:java}
java.lang.NullPointerException
at hudson.Util.isRelativePath(Util.java:557)
at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:642)
at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:432)
at hudson.plugins.ec2.win.EC2WindowsLauncher.launchScript(EC2WindowsLauncher.java:76)
at hudson.plugins.ec2.EC2ComputerLauncher.launch(EC2ComputerLauncher.java:48)
at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:294)
at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71)
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){code}

Jake.Remitz@carlsonwagonlit.com (JIRA)

unread,
Mar 29, 2019, 2:39:03 PM3/29/19
to jenkinsc...@googlegroups.com
Jake Remitz updated an issue
Change By: Jake Remitz
Labels: configuration-as-code ec2-plugin

o.v.nenashev@gmail.com (JIRA)

unread,
May 20, 2019, 5:59:02 PM5/20/19
to jenkinsc...@googlegroups.com
Oleg Nenashev updated an issue
Change By: Oleg Nenashev
Labels: configuration-as-code ec2-plugin jcasc-compatibility

timjacomb1@gmail.com (JIRA)

unread,
Jun 9, 2019, 11:45:03 AM6/9/19
to jenkinsc...@googlegroups.com

timjacomb1@gmail.com (JIRA)

unread,
Jun 9, 2019, 11:45:03 AM6/9/19
to jenkinsc...@googlegroups.com
Change By: Tim Jacomb
Status: Open Fixed but Unreleased
Resolution: Fixed

o.v.nenashev@gmail.com (JIRA)

unread,
Sep 16, 2019, 9:50:10 AM9/16/19
to jenkinsc...@googlegroups.com
Oleg Nenashev updated Bug JENKINS-56684
 

It was released in EC2 Plugin 1.44

Change By: Oleg Nenashev
Status: Fixed but Unreleased Resolved
Released As: EC2 Plugin 1.44
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages