Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-72938

NullPointerException when loading libvirt agents from JCasC

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • libvirt-slave-plugin
    • None

      As mentioned in JENKINS-72362, a missing 'nodeDescription' and 'nodeProperties' field causes the Jenkins server to fail to load libvirt agents via JCasC.  The full stack trace is

      java.lang.NullPointerException
          at java.base/java.util.ArrayList.<init>(ArrayList.java:179)
          at hudson.util.CopyOnWriteList.replaceBy(CopyOnWriteList.java:130)
          at hudson.util.PersistedList.replaceBy(PersistedList.java:95)
          at hudson.model.Slave.setNodeProperties(Slave.java:311)
          at hudson.plugins.libvirt.VirtualMachineSlave.<init>(VirtualMachineSlave.java:96)
      Caused: java.lang.reflect.InvocationTargetException
          at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
          at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
          at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
          at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:181)
      Caused: io.jenkins.plugins.casc.ConfiguratorException: virtualMachineSlave: Failed to construct instance of class hudson.plugins.libvirt.VirtualMachineSlave.
       Constructor: public hudson.plugins.libvirt.VirtualMachineSlave(java.lang.String,java.lang.String,java.lang.String,java.lang.String,hudson.model.Node$Mode,java.lang.String,hudson.plugins.libvirt.VirtualMachineLauncher,hudson.slaves.ComputerLauncher,hudson.slaves.RetentionStrategy,java.util.List,java.lang.String,java.lang.String,java.lang.String,int,java.lang.String,boolean,int,java.lang.String) throws hudson.model.Descriptor$FormException,java.io.IOException.
       Arguments: [java.lang.String, null, java.lang.String, java.lang.String, hudson.model.Node$Mode, java.lang.String, hudson.plugins.libvirt.VirtualMachineLauncher, hudson.slaves.JNLPLauncher, hudson.slaves.RetentionStrategy$Always, null, java.lang.String, java.lang.String, java.lang.String, java.lang.Integer, java.lang.String, java.lang.Boolean, java.lang.Integer, java.lang.String].
       Expected Parameters: name java.lang.String, nodeDescription java.lang.String, remoteFS java.lang.String, numExecutors java.lang.String, mode hudson.model.Node$Mode, labelString java.lang.String, launcher hudson.plugins.libvirt.VirtualMachineLauncher, delegateLauncher hudson.slaves.ComputerLauncher, retentionStrategy hudson.slaves.RetentionStrategy<? extends hudson.model.Computer>, nodeProperties java.util.List<? extends hudson.slaves.NodeProperty<?>>, hypervisorDescription java.lang.String, virtualMachineName java.lang.String, snapshotName java.lang.String, startupWaitingPeriodSeconds int, shutdownMethod java.lang.String, rebootAfterRun boolean, startupTimesToRetryOnFailure int, beforeJobSnapshotName java.lang.String
          at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:203)
          at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.instance(DataBoundConfigurator.java:75)
          at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:274)
          at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.configure(DataBoundConfigurator.java:81)
          at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.lambda$doConfigure$16668e2$1(HeteroDescribableConfigurator.java:311)
          at io.vavr.CheckedFunction0.lambda$unchecked$52349c75$1(CheckedFunction0.java:247)
          at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.doConfigure(HeteroDescribableConfigurator.java:311)
          at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.lambda$configure$2(HeteroDescribableConfigurator.java:88)
          at io.vavr.control.Option.map(Option.java:392)
          at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.lambda$configure$3(HeteroDescribableConfigurator.java:88)
          at io.vavr.Tuple2.apply(Tuple2.java:238)
          at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.configure(HeteroDescribableConfigurator.java:86)
          at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.check(HeteroDescribableConfigurator.java:94)
          at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.check(HeteroDescribableConfigurator.java:57)
          at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:355)
          at io.jenkins.plugins.casc.BaseConfigurator.check(BaseConfigurator.java:293)
          at io.jenkins.plugins.casc.ConfigurationAsCode.lambda$checkWith$9(ConfigurationAsCode.java:830)
          at io.jenkins.plugins.casc.ConfigurationAsCode.invokeWith(ConfigurationAsCode.java:773)
          at io.jenkins.plugins.casc.ConfigurationAsCode.checkWith(ConfigurationAsCode.java:830)
          at io.jenkins.plugins.casc.ConfigurationAsCode.configureWith(ConfigurationAsCode.java:816)
          at io.jenkins.plugins.casc.ConfigurationAsCode.configureWith(ConfigurationAsCode.java:695)
          at io.jenkins.plugins.casc.ConfigurationAsCode.configure(ConfigurationAsCode.java:352)
          at io.jenkins.plugins.casc.ConfigurationAsCode.init(ConfigurationAsCode.java:341)
      Caused: io.jenkins.plugins.casc.ConfigurationAsCodeBootFailure
          at io.jenkins.plugins.casc.ConfigurationAsCode.init(ConfigurationAsCode.java:343)
      Caused: java.lang.reflect.InvocationTargetException
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.base/java.lang.reflect.Method.invoke(Method.java:566)
          at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:109)
      Caused: java.lang.Error
          at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:115)
          at hudson.init.TaskMethodFinder$TaskImpl.run(TaskMethodFinder.java:185)
          at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:305)
          at jenkins.model.Jenkins$5.runTask(Jenkins.java:1166)
          at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:221)
          at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:120)
          at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
          at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
          at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
          at java.base/java.lang.Thread.run(Thread.java:829)
      Caused: org.jvnet.hudson.reactor.ReactorException
          at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:290)
          at jenkins.InitReactorRunner.run(InitReactorRunner.java:49)
          at jenkins.model.Jenkins.executeReactor(Jenkins.java:1201)
          at jenkins.model.Jenkins.<init>(Jenkins.java:989)
          at hudson.model.Hudson.<init>(Hudson.java:86)
          at hudson.model.Hudson.<init>(Hudson.java:82)
          at hudson.WebAppMain$3.run(WebAppMain.java:247)
      Caused: hudson.util.HudsonFailedToLoad
          at hudson.WebAppMain$3.run(WebAppMain.java:264) 

      An example of broken agent JCasC:

        - virtualMachineSlave:
            beforeJobSnapshotName: "BuildImage"
            delegateLauncher:
              inbound:
                workDirSettings:
                  disabled: false
                  failIfWorkDirIsMissing: false
                  internalDir: "remoting"
            hypervisorDescription: "QEMU+ssh - REDACTED"
            labelString: "Fedora-prev Fedora-38"
            launcher:
              delegate:
                inbound:
                  workDirSettings:
                    disabled: false
                    failIfWorkDirIsMissing: false
                    internalDir: "remoting"
              hypervisorDescription: "QEMU+ssh - REDACTED"
              timesToRetryOnFailure: 0
              virtualMachineName: "Fedora-38"
              waitingTimeSecs: 60
            mode: EXCLUSIVE
            name: "Fedora-38"
            numExecutors: 1
            rebootAfterRun: true
            remoteFS: "/home/REDACTED"
            retentionStrategy: "always"
            shutdownMethod: "shutdown"
            snapshotName: "BuildImage"
            startupTimesToRetryOnFailure: 0
            startupWaitingPeriodSeconds: 60
            virtualMachineName: "Fedora-38" 

      An example of working JCasC:

        - virtualMachineSlave:
            beforeJobSnapshotName: "BuildImage"
            delegateLauncher:
              inbound:
                workDirSettings:
                  disabled: false
                  failIfWorkDirIsMissing: false
                  internalDir: "remoting"
            hypervisorDescription: "QEMU+ssh - REDACTED"
            labelString: "Fedora-prev Fedora-38"
            launcher:
              delegate:
                inbound:
                  workDirSettings:
                    disabled: false
                    failIfWorkDirIsMissing: false
                    internalDir: "remoting"
              hypervisorDescription: "QEMU+ssh - REDACTED"
              timesToRetryOnFailure: 0
              virtualMachineName: "Fedora-38"
              waitingTimeSecs: 60
            mode: EXCLUSIVE
            name: "Fedora-38"
            nodeDescription: "Fedora 38"
            nodeProperties: []
            numExecutors: 1
            rebootAfterRun: true
            remoteFS: "/home/REDACTED"
            retentionStrategy: "always"
            shutdownMethod: "shutdown"
            snapshotName: "BuildImage"
            startupTimesToRetryOnFailure: 0
            startupWaitingPeriodSeconds: 60
            virtualMachineName: "Fedora-38" 

      In order to workaround the issue:

      1. Set the "Description" field of the agent to a non-empty value.
      2. Check a box under "Node Properties"?  I just manually added 'nodeProperties: []' to the YAML file (note that Jenkins does *not* generate this for you when exporting configuration as JCasC).

            m_jeanson Michael
            wtcline_intc Wade
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: