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

Invalid class cast in Disk Usage Plugin when ItemGroup is not a TopLevelItem

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • disk-usage-plugin
    • None
    • Jenkins 2.38, Managed Scripts plugin 1.3, config file provider 2.15.1, promoted builds plugin 2.28, Oracle JDK 1.8.0_122, Windows Server 2008 R2
    • v1.0

      Plugin version 1.2.4, managed scripts were usable in build promotion processes (with Promoted Builds plugin version 2.28). After upgrading to version 1.3, the promotion process hangs and is unresponsive when trying to use managed scripts; if the script content is copied to the promotion directly, then the promotion succeeds. Seeing this with both command shell scripts and powershell scripts. Only way to clear the hung promotion out of the build executor is via jenkins restart. Also causing high CPU usage by jenkins/java.

      On the same build job, both command shell scripts and powershell scripts work during the normal build process (inside of "build steps").

          [JENKINS-40728] Invalid class cast in Disk Usage Plugin when ItemGroup is not a TopLevelItem

          Going to re-assign this to Oleg Nenashev, since he appears to be the primary maintainer for the Promoted Builds plugin, and it appears this may have more to do with the Promoted Builds plugin, and the changes in the Config File Provider plugin (I have looked at the changes in the Managed Scripts Plugin from 1.2.4 to 1.3, there doesn't seem to be anything that would break usage, particularly for a single plugin).

          Bryson Gibbons added a comment - Going to re-assign this to Oleg Nenashev, since he appears to be the primary maintainer for the Promoted Builds plugin, and it appears this may have more to do with the Promoted Builds plugin, and the changes in the Config File Provider plugin (I have looked at the changes in the Managed Scripts Plugin from 1.2.4 to 1.3, there doesn't seem to be anything that would break usage, particularly for a single plugin).

          Oleg Nenashev added a comment -

          The stack trace is completely about Disk Usage plugin. What makes you think it is related?
          Anyway, I need to know the version of the Disk Usage plugin on your instance, I doubt it's the newest one

          Oleg Nenashev added a comment - The stack trace is completely about Disk Usage plugin. What makes you think it is related? Anyway, I need to know the version of the Disk Usage plugin on your instance, I doubt it's the newest one

          Disk usage plugin 0.28

          On Tuesday I updated Jenkins, and the following plugins from the previous latest versions as of Monday December 19:
          Config File Provider (2.13 -> 2.15.1)
          Managed Scripts (1.2.4 -> 1.3)
          Email extension (2.52 -> 2.53)
          Github API plugin (1.80 -> 1.82)
          JIRA Plugin (2.2.1 -> 2.3)

          Prior to that update, build promotions using managed scripts worked; after, they hung. I performed a careful downgrade of just the Config File Provider and Managed scripts plugins, and the build promotions that use managed scripts work once again. So, I don't know if it is the promoted builds plugin or disk usage plugin that doesn't agree with the updated Config File Provider/Managed Scripts plugins, but that exception definitely does not occur after downgrading those plugins.

          Bryson Gibbons added a comment - Disk usage plugin 0.28 On Tuesday I updated Jenkins, and the following plugins from the previous latest versions as of Monday December 19: Config File Provider (2.13 -> 2.15.1) Managed Scripts (1.2.4 -> 1.3) Email extension (2.52 -> 2.53) Github API plugin (1.80 -> 1.82) JIRA Plugin (2.2.1 -> 2.3) Prior to that update, build promotions using managed scripts worked; after, they hung. I performed a careful downgrade of just the Config File Provider and Managed scripts plugins, and the build promotions that use managed scripts work once again. So, I don't know if it is the promoted builds plugin or disk usage plugin that doesn't agree with the updated Config File Provider/Managed Scripts plugins, but that exception definitely does not occur after downgrading those plugins.

          the only dependency between the promotion plugin and the config-file-provider/managed scripts plugins, is via the job-dsl plugin. And there is an open PR to solve the issue (JENKINS-39769): https://github.com/jenkinsci/job-dsl-plugin/pull/951

          Dominik Bartholdi added a comment - the only dependency between the promotion plugin and the config-file-provider/managed scripts plugins, is via the job-dsl plugin. And there is an open PR to solve the issue ( JENKINS-39769 ): https://github.com/jenkinsci/job-dsl-plugin/pull/951

          I don't have the job-dsl plugin installed.

          Bryson Gibbons added a comment - I don't have the job-dsl plugin installed.

          Oleg Nenashev added a comment -

          So the failing codeline is here: https://github.com/jenkinsci/disk-usage-plugin/blob/disk-usage-0.28/src/main/java/hudson/plugins/disk_usage/DiskUsageProperty.java#L342. Promoted Build's Job Property is an ItemGroup (https://github.com/jenkinsci/promoted-builds-plugin/blob/master/src/main/java/hudson/plugins/promoted_builds/JobPropertyImpl.java#L54), hence it can be legitimately returned in the owner.getParent() call.

          DiskUsage plugin performs the invalid and unchecked class cast, hence it is a root cause of the issue. Even if the issue appears during the upgrade of other plugins, Disk Usage Plugin is the one to be fixed.

          Oleg Nenashev added a comment - So the failing codeline is here: https://github.com/jenkinsci/disk-usage-plugin/blob/disk-usage-0.28/src/main/java/hudson/plugins/disk_usage/DiskUsageProperty.java#L342 . Promoted Build's Job Property is an ItemGroup ( https://github.com/jenkinsci/promoted-builds-plugin/blob/master/src/main/java/hudson/plugins/promoted_builds/JobPropertyImpl.java#L54 ), hence it can be legitimately returned in the owner.getParent() call. DiskUsage plugin performs the invalid and unchecked class cast, hence it is a root cause of the issue. Even if the issue appears during the upgrade of other plugins, Disk Usage Plugin is the one to be fixed.

          Oleg Nenashev added a comment -

          Reassigned the plugin to lvotypkova, who is a maintainer of the Disk Usage plugin

          Oleg Nenashev added a comment - Reassigned the plugin to lvotypkova , who is a maintainer of the Disk Usage plugin

          I have a new stack trace, after again upgrading to Config File Provider Plugin version 2.15.5 (previously upgraded to Config File provider version 2.15.1, which is now flagged as "DO NOT INSTALL" due to issues with Managed scripts/configs). This time the promotion fails quickly rather than endlessly running, and the exception now appears in the UI as follows:
          FATAL: can not determine current context/parent for: MyJob/promotion of type class hudson.plugins.promoted_builds.JobPropertyImpl
          java.lang.IllegalArgumentException: can not determine current context/parent for: MyJob/promotion of type class hudson.plugins.promoted_builds.JobPropertyImpl
          at org.jenkinsci.plugins.configfiles.ConfigFiles.getByIdOrNull(ConfigFiles.java:114)
          at org.jenkinsci.plugins.configfiles.ConfigFiles.getByIdOrNull(ConfigFiles.java:140)
          at org.jenkinsci.plugins.configfiles.ConfigFiles.getByIdOrNull(ConfigFiles.java:164)
          at org.jenkinsci.plugins.managedscripts.PowerShellBuildStep.getContents(PowerShellBuildStep.java:126)
          at hudson.tasks.CommandInterpreter.createScriptFile(CommandInterpreter.java:161)
          at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:93)
          at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:65)
          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)

          Bryson Gibbons added a comment - I have a new stack trace, after again upgrading to Config File Provider Plugin version 2.15.5 (previously upgraded to Config File provider version 2.15.1, which is now flagged as "DO NOT INSTALL" due to issues with Managed scripts/configs). This time the promotion fails quickly rather than endlessly running, and the exception now appears in the UI as follows: FATAL: can not determine current context/parent for: MyJob/promotion of type class hudson.plugins.promoted_builds.JobPropertyImpl java.lang.IllegalArgumentException: can not determine current context/parent for: MyJob/promotion of type class hudson.plugins.promoted_builds.JobPropertyImpl at org.jenkinsci.plugins.configfiles.ConfigFiles.getByIdOrNull(ConfigFiles.java:114) at org.jenkinsci.plugins.configfiles.ConfigFiles.getByIdOrNull(ConfigFiles.java:140) at org.jenkinsci.plugins.configfiles.ConfigFiles.getByIdOrNull(ConfigFiles.java:164) at org.jenkinsci.plugins.managedscripts.PowerShellBuildStep.getContents(PowerShellBuildStep.java:126) at hudson.tasks.CommandInterpreter.createScriptFile(CommandInterpreter.java:161) at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:93) at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:65) 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)

          Linking, because symptoms match

          Bryson Gibbons added a comment - Linking, because symptoms match

          Code changed in jenkins
          User: Lucie Votypkova
          Path:
          pom.xml
          src/test/java/hudson/plugins/disk_usage/integration/DiskUsagePropertyTest.java
          http://jenkins-ci.org/commit/disk-usage-plugin/5842185ddfcbfe9cec035dba3ed20a623ef1d60b
          Log:
          Reproduce issue JENKINS-40728

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Lucie Votypkova Path: pom.xml src/test/java/hudson/plugins/disk_usage/integration/DiskUsagePropertyTest.java http://jenkins-ci.org/commit/disk-usage-plugin/5842185ddfcbfe9cec035dba3ed20a623ef1d60b Log: Reproduce issue JENKINS-40728

            Unassigned Unassigned
            farmgeek4life Bryson Gibbons
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: