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

Cannot configure Nomad plugin with JCasC

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Blocker
    • Resolution: Cannot Reproduce
    • Component/s: nomad-plugin
    • Environment:
      Jenkins 2.176.1 (docker container)
      Nomad plugin 0.6.5
      JCasC plugin 1.23
    • Similar Issues:
    • Released As:
      Nomad Plugin 0.6.8

      Description

      JCasC plugin does not apply all of the 'Nomad plugin' related entries from jenkins.yaml although these entries are listed in the JSON schema (<jenkins_url>/configuration-as-code/schema).
      In the result the Nomad plugin is not well configured and java.lang.NullPointerException are caused in the plugin's code when a slave is set up (e.g. at org.jenkinsci.plugins.nomad.NomadApi.buildDriverConfig(NomadApi.java:142)).

      The missing entries in my case are

      • org.jenkinsci.plugins.nomad.NomadCloud.jenkinsTunnel
      • org.jenkinsci.plugins.nomad.NomadSlaveTemplate.remoteFs
      • org.jenkinsci.plugins.nomad.NomadSlaveTemplate.prefixCmd

      If I add them manually to the Jenkins' config.xml the setup of a Nomad slave succeeds.

      Beside that the export of the configuration causes an StackOverflowError:

      FAILED TO EXPORT
      org.jenkinsci.plugins.nomad.NomadSlaveTemplate#cloud: java.lang.StackOverflowError
      at java.util.Collections$UnmodifiableCollection$1.<init>(Collections.java:1039)
      at java.util.Collections$UnmodifiableCollection.iterator(Collections.java:1038)
      ...
      Caused: java.lang.reflect.InvocationTargetException
      at sun.reflect.GeneratedConstructorAccessor133.newInstance(Unknown Source)
      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.describe(DataBoundConfigurator.java:265)
      at io.jenkins.plugins.casc.Attribute.describe(Attribute.java:202)
      at io.jenkins.plugins.casc.BaseConfigurator.compare(BaseConfigurator.java:391)
      at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.describe(DataBoundConfigurator.java:268)
      at io.jenkins.plugins.casc.Attribute.describe(Attribute.java:198)

      This seems to be caused by recursive loop: The cloud definition contains an arry of node templates. Each template definition contains a cloud object which references the cloud object which this template list belongs to.

        Attachments

          Activity

          Hide
          pisence Christian Kanthak added a comment -

          It pointed out that the missing configuration of

          • org.jenkinsci.plugins.nomad.NomadCloud.jenkinsTunnel
          • org.jenkinsci.plugins.nomad.NomadSlaveTemplate.remoteFs
          • org.jenkinsci.plugins.nomad.NomadSlaveTemplate.prefixCmd

          was caused by an error of our automatic setup (which led to a missing update of jenkins.yaml).
          I will resolve this issue.

          However, it is required to configure these values (also they are empty strings) otherwise java.lang.NullPointerException occur in the NomadAPI.java as mentioned above.

          Beside that the StackOverflowError is still caused when exporting configuration of such system with casc plugin.

          This recursive definition of nomad cloud (once as top level and then for every slave in templates) enforced us to repeat all values. Here it would be nice to just mention the 'name' property for a slave template to assign the corresponding cloud.
          If someone arrives here looking for a definition of nomad cloud and slave via casc this worked for us:

          jenkins:
            clouds:
            - nomad:
                jenkinsTunnel: ''
                jenkinsUrl: https://jenkins.url
                name: nomad_cloud
                nomadACLCredentialsId: ''
                nomadUrl: http://nomad.url
                prune: true
                slaveUrl: https://jenkins.url/jnlpJars/slave.jar
                workerTimeout: 1
                templates:
                - cloud:
                    jenkinsTunnel: ''
                    jenkinsUrl: https://jenkins.url
                    name: nomad_cloud
                    nomadACLCredentialsId: ''
                    nomadUrl: http://nomad.url
                    prune: true
                    slaveUrl: https://jenkins.url/jnlpJars/slave.jar
                    workerTimeout: 1
                  cpu: 512
                  datacenters: data_center
                  disk: 4000
                  forcePull: true
                  hostVolumes: "/etc/ssl/cacerts:/usr/local/openjdk-8/jre/lib/security/cacerts,"
                  idleTerminationInMinutes: 10
                  image: jenkins/slave:3.29-2
                  labels: nomad_slave
                  memory: 1024
                  mode: NORMAL
                  network: bridge
                  numExecutors: 1
                  prefix: jenkins_
                  prefixCmd: ''
                  priority: 50
                  privileged: false
                  region: global
                  remoteFs: ''
                  reusable: true
          
          Show
          pisence Christian Kanthak added a comment - It pointed out that the missing configuration of org.jenkinsci.plugins.nomad.NomadCloud.jenkinsTunnel org.jenkinsci.plugins.nomad.NomadSlaveTemplate.remoteFs org.jenkinsci.plugins.nomad.NomadSlaveTemplate.prefixCmd was caused by an error of our automatic setup (which led to a missing update of jenkins.yaml). I will resolve this issue. However, it is required to configure these values (also they are empty strings) otherwise java.lang.NullPointerException occur in the NomadAPI.java as mentioned above. Beside that the StackOverflowError is still caused when exporting configuration of such system with casc plugin. This recursive definition of nomad cloud (once as top level and then for every slave in templates) enforced us to repeat all values. Here it would be nice to just mention the 'name' property for a slave template to assign the corresponding cloud. If someone arrives here looking for a definition of nomad cloud and slave via casc this worked for us: jenkins: clouds: - nomad: jenkinsTunnel: '' jenkinsUrl: https://jenkins.url name: nomad_cloud nomadACLCredentialsId: '' nomadUrl: http://nomad.url prune: true slaveUrl: https://jenkins.url/jnlpJars/slave.jar workerTimeout: 1 templates: - cloud: jenkinsTunnel: '' jenkinsUrl: https://jenkins.url name: nomad_cloud nomadACLCredentialsId: '' nomadUrl: http://nomad.url prune: true slaveUrl: https://jenkins.url/jnlpJars/slave.jar workerTimeout: 1 cpu: 512 datacenters: data_center disk: 4000 forcePull: true hostVolumes: "/etc/ssl/cacerts:/usr/local/openjdk-8/jre/lib/security/cacerts," idleTerminationInMinutes: 10 image: jenkins/slave:3.29-2 labels: nomad_slave memory: 1024 mode: NORMAL network: bridge numExecutors: 1 prefix: jenkins_ prefixCmd: '' priority: 50 privileged: false region: global remoteFs: '' reusable: true
          Hide
          multani Jonathan Ballet added a comment -

          FYI, this has been reported upstream in https://github.com/jenkinsci/nomad-plugin/issues/54

          Show
          multani Jonathan Ballet added a comment - FYI, this has been reported upstream in https://github.com/jenkinsci/nomad-plugin/issues/54

            People

            Assignee:
            iverberk Ivo Verberk
            Reporter:
            pisence Christian Kanthak
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: