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

Endless Loop when "provisoning config files..." when run from a build promotion

      My symptom is when I click promote I get the following output:

      Started by user XXX@mydomain.com
      Building on master in workspace /var/lib/jenkins/jobs/Package for Release /workspace
      Promoting JOB BEING PROMOTED
      provisoning config files...

      And it sits there...

      A snapshot of the stack trace is:

      at org.jenkinsci.plugins.configfiles.ConfigFiles.getByIdOrNull(ConfigFiles.java:82)
      at org.jenkinsci.plugins.configfiles.ConfigFiles.getByIdOrNull(ConfigFiles.java:103)
      at org.jenkinsci.plugins.configfiles.ConfigFiles.getByIdOrNull(ConfigFiles.java:114)
      at org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFileUtil.provisionConfigFiles(ManagedFileUtil.java:81)
      at org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep.perform(ConfigFileBuildStep.java:61)
      at hudson.plugins.promoted_builds.Promotion$RunnerImpl.build(Promotion.java:405)
      at hudson.plugins.promoted_builds.Promotion$RunnerImpl.doRun(Promotion.java:347)
      at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
      at hudson.model.Run.execute(Run.java:1729)
      at hudson.model.Run.run(Run.java:1688)
      at hudson.plugins.promoted_builds.Promotion.run(Promotion.java:286)
      at hudson.model.ResourceController.execute(ResourceController.java:98)
      at hudson.model.Executor.run(Executor.java:404)

      This method: getByIdOrNull at the plugin version I'm on (config files provider: 2.15.1) is the following:

          public static <T extends Config> T getByIdOrNull(@Nullable ItemGroup itemGroup, @NonNull String configId) {
      
              while (itemGroup != null) {
                  if (folderPluginInstalled() && itemGroup instanceof AbstractFolder) {
                      final AbstractFolder<?> folder = AbstractFolder.class.cast(itemGroup);
                      ConfigFileStore store = folder.getProperties().get(FolderConfigFileProperty.class);
                      if (store != null) {
                          Config config = store.getById(configId);
                          if (config != null) {
                              return (T) config;
                          }
                      }
                  }
                  if (itemGroup instanceof Item) {
                      itemGroup = Item.class.cast(itemGroup).getParent();
                  }
                  if (itemGroup instanceof Jenkins) {
                      // we are on top scope...
                      return (T) GlobalConfigFiles.get().getById(configId);
                  } else {
                      continue;
                  }
              }
      
              return null;
          }
      

      After attaching the debugger I've found that the reason I'm getting this behaviour is because this method does not return.

      It just loops around and around.

      The real type of the passed in itemGroup is hudson.plugins.promoted_builds.JobPropertyImpl

      1. Folder Plugins is installed but itemGroup is not an instance of AbstractFolder
      2. JobPropertyImpl is not an instance of Item
      3. JobPropertyImpl is not an instance of Jenkins either.

      So this method will never return.

      What is more is the configId that is passed in is valid as if I call GlobalConfigFiles.get().getById(configId); I get back what I expect.

      I suspect that 3rd condition probably needs to be relaxed a little...

          [JENKINS-40803] Endless Loop when "provisoning config files..." when run from a build promotion

          If the fix is in the source code, can we get an updated plugin?

          linda mcdonald added a comment - If the fix is in the source code, can we get an updated plugin?

          just to be clear, this can not be fixed in the config-file-provider plugin only, the but must first be changed in the promoted-build-plugin

          Dominik Bartholdi added a comment - just to be clear, this can not be fixed in the config-file-provider plugin only, the but must first be changed in the promoted-build-plugin

          Michael Wiles added a comment -

          Agreed that https://github.com/FarmGeek4Life/promoted-builds-plugin/commit/230d61070b3883234f43db7eb0090ddaa782fb62 will work. Though making JobPropertyImpl implement Item is not a great fit as most of the methods required by Item are left unimplemented. At least it works for the config file provider - and I need the promoted builds to work with config files.

          With regards to folders etc, as it was it would not have worked whether folders were present or not as it would not have been able to get out of the specific job scope. I guess the question is - since I also don't use folders - is will this fix work if the job is in a folder and the config files are bundled in a folder.

          Michael Wiles added a comment - Agreed that https://github.com/FarmGeek4Life/promoted-builds-plugin/commit/230d61070b3883234f43db7eb0090ddaa782fb62  will work. Though making JobPropertyImpl implement Item is not a great fit as most of the methods required by Item are left unimplemented. At least it works for the config file provider - and I need the promoted builds to work with config files. With regards to folders etc, as it was it would not have worked whether folders were present or not as it would not have been able to get out of the specific job scope. I guess the question is - since I also don't use folders - is will this fix work if the job is in a folder and the config files are bundled in a folder.

          farmgeek4life I've rebased your patch on latest master here https://github.com/ydubreuil/promoted-builds-plugin/tree/fix-JENKINS-40803 . Do you mind if I fill  a PR with your fix?

          Yoann Dubreuil added a comment - farmgeek4life I've rebased your patch on latest master here https://github.com/ydubreuil/promoted-builds-plugin/tree/fix-JENKINS-40803 . Do you mind if I fill  a PR with your fix?

          Code changed in jenkins
          User: Arnaud
          Path:
          src/main/java/org/jenkinsci/plugins/configfiles/ConfigContextResolver.java
          src/main/java/org/jenkinsci/plugins/configfiles/ConfigFiles.java
          src/test/java/org/jenkinsci/plugins/configfiles/ConfigFilesTest.java
          http://jenkins-ci.org/commit/config-file-provider-plugin/48087c5c624cf64497600101258d5d718ef5fad6
          Log:
          JENKINS-40803 allow plugins to specify the config file resolution context

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Arnaud Path: src/main/java/org/jenkinsci/plugins/configfiles/ConfigContextResolver.java src/main/java/org/jenkinsci/plugins/configfiles/ConfigFiles.java src/test/java/org/jenkinsci/plugins/configfiles/ConfigFilesTest.java http://jenkins-ci.org/commit/config-file-provider-plugin/48087c5c624cf64497600101258d5d718ef5fad6 Log: JENKINS-40803 allow plugins to specify the config file resolution context

          Code changed in jenkins
          User: Dominik Bartholdi
          Path:
          src/main/java/org/jenkinsci/plugins/configfiles/ConfigContextResolver.java
          src/main/java/org/jenkinsci/plugins/configfiles/ConfigFiles.java
          src/test/java/org/jenkinsci/plugins/configfiles/ConfigFilesTest.java
          http://jenkins-ci.org/commit/config-file-provider-plugin/e76cff0a590bb4083cb2e120304f55d8e2d75267
          Log:
          Merge pull request #49 from Greybird/master

          JENKINS-40803 allow plugins to specify the config file resolution context

          Compare: https://github.com/jenkinsci/config-file-provider-plugin/compare/b5b4d0dcdf57...e76cff0a590b

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Dominik Bartholdi Path: src/main/java/org/jenkinsci/plugins/configfiles/ConfigContextResolver.java src/main/java/org/jenkinsci/plugins/configfiles/ConfigFiles.java src/test/java/org/jenkinsci/plugins/configfiles/ConfigFilesTest.java http://jenkins-ci.org/commit/config-file-provider-plugin/e76cff0a590bb4083cb2e120304f55d8e2d75267 Log: Merge pull request #49 from Greybird/master JENKINS-40803 allow plugins to specify the config file resolution context Compare: https://github.com/jenkinsci/config-file-provider-plugin/compare/b5b4d0dcdf57...e76cff0a590b

          released with 1.8

          Dominik Bartholdi added a comment - released with 1.8

          Code changed in jenkins
          User: Arnaud
          Path:
          pom.xml
          src/main/java/hudson/plugins/promoted_builds/JobPropertyImplConfigContextResolver.java
          src/test/java/hudson/plugins/promoted_builds/PromotionConfigFilesTest.java
          http://jenkins-ci.org/commit/promoted-builds-plugin/d61798e40933d8bacadb9c37820bf6ce0e67f072
          Log:
          JENKINS-40803 provide a config file resolution context for promotions

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Arnaud Path: pom.xml src/main/java/hudson/plugins/promoted_builds/JobPropertyImplConfigContextResolver.java src/test/java/hudson/plugins/promoted_builds/PromotionConfigFilesTest.java http://jenkins-ci.org/commit/promoted-builds-plugin/d61798e40933d8bacadb9c37820bf6ce0e67f072 Log: JENKINS-40803 provide a config file resolution context for promotions

          Code changed in jenkins
          User: Devin Nusbaum
          Path:
          pom.xml
          src/main/java/hudson/plugins/promoted_builds/JobPropertyImplConfigContextResolver.java
          src/test/java/hudson/plugins/promoted_builds/PromotionConfigFilesTest.java
          http://jenkins-ci.org/commit/promoted-builds-plugin/9d0530121fa48d1a581cdd61472a98519d58463e
          Log:
          Merge pull request #113 from Greybird/master

          JENKINS-40803 provide a config file resolution context for promotions

          Compare: https://github.com/jenkinsci/promoted-builds-plugin/compare/03852505496a...9d0530121fa4

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Devin Nusbaum Path: pom.xml src/main/java/hudson/plugins/promoted_builds/JobPropertyImplConfigContextResolver.java src/test/java/hudson/plugins/promoted_builds/PromotionConfigFilesTest.java http://jenkins-ci.org/commit/promoted-builds-plugin/9d0530121fa48d1a581cdd61472a98519d58463e Log: Merge pull request #113 from Greybird/master JENKINS-40803 provide a config file resolution context for promotions Compare: https://github.com/jenkinsci/promoted-builds-plugin/compare/03852505496a...9d0530121fa4

          Devin Nusbaum added a comment -

          Fixed in config-file-provider:2.18 and promoted-builds:3.1. Thanks greybird for fixing this!

          Devin Nusbaum added a comment - Fixed in config-file-provider:2.18 and promoted-builds:3.1 . Thanks greybird for fixing this!

            farmgeek4life Bryson Gibbons
            michaelwiles Michael Wiles
            Votes:
            3 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated:
              Resolved: