jenkinsci / nomad-plugin

Nomad cloud plugin for Jenkins
https://plugins.jenkins.io/nomad/
MIT License
56 stars 41 forks source link

Unable to export configuration as code #54

Closed multani closed 5 years ago

multani commented 5 years ago

I tried a basic Jenkins installation with the Nomad Plugin and the Configuration as code plugin.

I setup a new "Nomad cloud" with a super basic template as in the screenshot (the other fields are empty):

image

Then, exporting this configuration using JENKINS/configuration-as-code/viewExport produces an infinite loop followed by a java.lang.StackOverflowError error.

The exported YAML configuration by the "Configuration as code" plugin, when it manages to output something, produces something like:

jenkins:
  agentProtocols:
  - "JNLP4-connect"
  - "Ping"
  authorizationStrategy:
    loggedInUsersCanDoAnything:
      allowAnonymousRead: false
  clouds:
  - nomad:
      jenkinsUrl: "http://localhost:8080/"
      name: "nomad"
      nomadUrl: "http://127.0.0.1:4646"
      prune: false
      slaveUrl: "http://localhost:8080/jnlpJars/slave.jar"
      templates:
      - cloud:
          jenkinsUrl: "http://localhost:8080/"
          name: "nomad"
          nomadUrl: "http://127.0.0.1:4646"
          prune: false
          slaveUrl: "http://localhost:8080/jnlpJars/slave.jar"
          templates:
          - cloud:
              jenkinsUrl: "http://localhost:8080/"
              name: "nomad"
              nomadUrl: "http://127.0.0.1:4646"
              prune: false
              slaveUrl: "http://localhost:8080/jnlpJars/slave.jar"
              templates:
              - cloud:
                  jenkinsUrl: "http://localhost:8080/"
                  name: "nomad"
                  nomadUrl: "http://127.0.0.1:4646"
                  prune: false
                  slaveUrl: "http://localhost:8080/jnlpJars/slave.jar"
                  templates:
                  - cloud:
                      jenkinsUrl: "http://localhost:8080/"
                      name: "nomad"
                      nomadUrl: "http://127.0.0.1:4646"
                      prune: false
                      slaveUrl: "http://localhost:8080/jnlpJars/slave.jar"
                      templates:
                      - cloud:
                          jenkinsUrl: "http://localhost:8080/"
                          name: "nomad"
                          nomadUrl: "http://127.0.0.1:4646"
                          prune: false
                          slaveUrl: "http://localhost:8080/jnlpJars/slave.jar"
                          templates:
                          - cloud:
                              ... # repeats ad vitam æternam

There's the related issue JENKINS-58491 on Jira but it pings Ivo Verberk and the issue has been closed since then, although I think the original recursion problem describe in the issue is actually still present in the plugin.

It would be cool if we could use both plugins together and backup/reconfigure the Nomad Plugin configuration using the Configuration as Code plugin! :+1:

phedoreanu commented 5 years ago

@multani I use the SCM Sync configuration plugin and it's able to export the whole config.xml which contains the Nomad Cloud config:

Screenshot 2019-08-02 11 55 08
multani commented 5 years ago

@phedoreanu That's good to know it works in other cases as well!

SCM Sync seems to be unmaintained and deprecated in favor of "Configuration as code" though, so it might still be worthwhile to have a look at why it goes into this infinite recursive loop.

phedoreanu commented 5 years ago

Go for it, if you have the time and energy ;)

multani commented 5 years ago

I'll give it a shot here.