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

installNecessaryPlugins API redirects to a non-existent page, returns 404

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • core
    • jenkins-2.375.1 and later
    • 2.393 and 2.387.2

      We use the pluginManager API to automate plugin updates on all of our Jenkins instances. This worked really well for a long time. Since a few weeks it stopped working.

      When sending a POST request to /pluginManager/installNecessaryPlugins with the plugins to be updated it gets redirected to /updates/ with status 404.

       

      I'm sending the request like this:
      curl --request POST \
      --url http://localhost:8080/pluginManager/installNecessaryPlugins \
      --header 'Authorization: Basic <redacted-token>' \
      --header 'Content-Type: application/xml' \
      --data '<jenkins><install plugin="mattermost@3.1.2"></install></jenkins>'
       
      And I get this response:
      <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
      <title>Error 404 Not Found</title>
      </head>
      <body><h2>HTTP ERROR 404 Not Found</h2>
      <table>
      <tr><th>URI:</th><td>/updates/</td></tr>
      <tr><th>STATUS:</th><td>404</td></tr>
      <tr><th>MESSAGE:</th><td>Not Found</td></tr>
      <tr><th>SERVLET:</th><td>Stapler</td></tr>
      </table>
      <hr/><a href="https://eclipse.org/jetty">Powered by Jetty:// 10.0.12</a><hr/>

      </body>
      </html>

      Did anything drastically change in the API? From the docs and release notes i couldn't figure out if something has changed.

       

      Looking forward to an answer on this.

       

        1. plugins.txt
          0.8 kB
        2. run-jenkins.sh
          0.9 kB
        3. update-plugin.sh
          0.6 kB
        4. update-plugin-follow-redirect.sh
          0.7 kB

          [JENKINS-70599] installNecessaryPlugins API redirects to a non-existent page, returns 404

          Mark Waite added a comment -

          You might check if you're using a reverse proxy and something has changed in the configuration of the reverse proxy. If that doesn't work, you could compare the differences in the source code between the versions that were working before and the current versions, in case there is something in those changes that might hint at a difference. I'm not sure that others will be able to help you without a way to duplicate the problem in their environment.

          Mark Waite added a comment - You might check if you're using a reverse proxy and something has changed in the configuration of the reverse proxy. If that doesn't work, you could compare the differences in the source code between the versions that were working before and the current versions, in case there is something in those changes that might hint at a difference. I'm not sure that others will be able to help you without a way to duplicate the problem in their environment.

          Marco added a comment -

          markewaite 

          I did some digging and found that the redirect for installNecessaryPlugins has been changed in this PR: https://github.com/jenkinsci/jenkins/pull/6783/files#diff-0dd3c7930da03922fff631a2cf06fbfda9b9bc688a4e5804fceda225147778a6L1596

          https://localhost:8080/updates/ does not exist thus I get a 404 status.

          The plugin still seems to get installed but this breaks my automation I have built around it. Since the call to installNecessaryPlugins returns an error my automation will not trigger a safeRestart.

          Shouldn't a request to http://localhost:8080/pluginManager/installNecessaryPlugins get redirected to http://localhost:8080/pluginManager/updates/ as mentioned here: https://github.com/jenkinsci/jenkins/pull/6783/files#diff-0dd3c7930da03922fff631a2cf06fbfda9b9bc688a4e5804fceda225147778a6R1392 ?

           

          Marco added a comment - markewaite   I did some digging and found that the redirect for installNecessaryPlugins has been changed in this PR: https://github.com/jenkinsci/jenkins/pull/6783/files#diff-0dd3c7930da03922fff631a2cf06fbfda9b9bc688a4e5804fceda225147778a6L1596 https://localhost:8080/updates/ does not exist thus I get a 404 status. The plugin still seems to get installed but this breaks my automation I have built around it. Since the call to installNecessaryPlugins returns an error my automation will not trigger a safeRestart. Shouldn't a request to http://localhost:8080/pluginManager/installNecessaryPlugins get redirected to http://localhost:8080/pluginManager/updates/ as mentioned here: https://github.com/jenkinsci/jenkins/pull/6783/files#diff-0dd3c7930da03922fff631a2cf06fbfda9b9bc688a4e5804fceda225147778a6R1392 ?  

          Apoorva added a comment -

          I'm seeing the exact same error as well after bringing up a Jenkins with version 2.375.1.

          It works fine with older version of Jenkins.

           

          We have a wrapper script in go that uses go clinet to install plugin. I've been trying to figure out a way to get this working as I need to test with around 500 plugins. And it's impossible to do this manually.

          Apoorva added a comment - I'm seeing the exact same error as well after bringing up a Jenkins with version 2.375.1. It works fine with older version of Jenkins.   We have a wrapper script in go that uses go clinet to install plugin. I've been trying to figure out a way to get this working as I need to test with around 500 plugins. And it's impossible to do this manually.

          Mark Waite added a comment - - edited

          I think you're right that it is a bug. I can see the failed redirect if I add the --location argument to my curl command. I think that hints that one workaround might be to make the HTTP POST not follow the redirect when you perform the HTTP POST.

          I need to do more investigation to understand why that was never seen during interactive use of the plugin manager.

          I can see the bug with the following steps:

          1. Define a a set of plugins with 3 outdated plugins in plugins.txt (git plugin, git client plugin, and trilead api plugin are outdated)
          2. Download and run Jenkins 2.375.3 and that set of plugins with the script run-jenkins.sh
          3. Complete the setup wizard by installing no additional plugins and creating the user mwaite with the password mwaite
          4. Confirm in the plugin manager page that 3 plugins are outdated, the git plugin, git client plugin, and trilead api plugin
          5. Run the update-plugin-follow-redirect.sh shell script that requests a crumb and stores a cookie then submits the call to installNecessaryPlugins requesting git plugin 5.0.0 with the curl option to follow redirects
          6. Confirm that the curl command reports a 404 for the redirection to http://localhost:8080/updates/ . The old redirect to http://localhost:8080/updateCenter still works, but I think that would redirect the user to a legacy page that does not have the navigation on the side bar
          7. Confirm in the plugin manager page that 3 plugins are scheduled to be updated on next restart, the git plugin, git client plugin, and trilead api plugin
          8. Restart Jenkins and confirm that the 3 plugins were updated

          I need help from others who better understand the redirects in PluginManager.java. janfaracik can you offer guidance?

          Mark Waite added a comment - - edited I think you're right that it is a bug. I can see the failed redirect if I add the --location argument to my curl command. I think that hints that one workaround might be to make the HTTP POST not follow the redirect when you perform the HTTP POST. I need to do more investigation to understand why that was never seen during interactive use of the plugin manager. I can see the bug with the following steps: Define a a set of plugins with 3 outdated plugins in plugins.txt (git plugin, git client plugin, and trilead api plugin are outdated) Download and run Jenkins 2.375.3 and that set of plugins with the script run-jenkins.sh Complete the setup wizard by installing no additional plugins and creating the user mwaite with the password mwaite Confirm in the plugin manager page that 3 plugins are outdated, the git plugin, git client plugin, and trilead api plugin Run the update-plugin-follow-redirect.sh shell script that requests a crumb and stores a cookie then submits the call to installNecessaryPlugins requesting git plugin 5.0.0 with the curl option to follow redirects Confirm that the curl command reports a 404 for the redirection to http://localhost:8080/updates/ . The old redirect to http://localhost:8080/updateCenter still works, but I think that would redirect the user to a legacy page that does not have the navigation on the side bar Confirm in the plugin manager page that 3 plugins are scheduled to be updated on next restart, the git plugin, git client plugin, and trilead api plugin Restart Jenkins and confirm that the 3 plugins were updated I need help from others who better understand the redirects in PluginManager.java. janfaracik can you offer guidance?

          Mark Waite added a comment - - edited

          apoorva_m and marcodl a preliminary build of PR-7653 is available. That code change resolved the issue that I was seeing. I'd like your confirmation that it resolves your issues as well.

          The pull request is a draft because it needs an automated test that shows the failure without the change and confirms the change fixes the failure.

          Mark Waite added a comment - - edited apoorva_m and marcodl a preliminary build of PR-7653 is available. That code change resolved the issue that I was seeing. I'd like your confirmation that it resolves your issues as well. The pull request is a draft because it needs an automated test that shows the failure without the change and confirms the change fixes the failure.

          Marco added a comment -

          markewaite 

           

          I have just tested our integration with the version 2.392-rc33365.296a_73876a_7a_.
          I can confirm that with that version everything works as expected.

           

          Will this change get merged in the next LTS release?

          Marco added a comment - markewaite     I have just tested our integration with the version 2.392-rc33365.296a_73876a_7a_. I can confirm that with that version everything works as expected.   Will this change get merged in the next LTS release?

          Mark Waite added a comment -

          I've labeled the issue as an lts-candidate so that it can be considered for inclusion in the next LTS.

          The change needs to be included in a weekly release before it can be considered for LTS. Before it can be included in a weekly release, it needs to be reviewed and merged. Before it can be reviewed and merged, it needs an automated test.

          Mark Waite added a comment - I've labeled the issue as an lts-candidate so that it can be considered for inclusion in the next LTS. The change needs to be included in a weekly release before it can be considered for LTS. Before it can be included in a weekly release, it needs to be reviewed and merged. Before it can be reviewed and merged, it needs an automated test.

          Mark Waite added a comment -

          Test has been written and verified that it shows the failure with Jenkins 2.375.1 and does not show a failure with Jenkins 2.361.4. Ready for review.

          Mark Waite added a comment - Test has been written and verified that it shows the failure with Jenkins 2.375.1 and does not show a failure with Jenkins 2.361.4. Ready for review.

          Mark Waite added a comment -

          Merged in preparation for 2.393 release

          Mark Waite added a comment - Merged in preparation for 2.393 release

          Mark Waite added a comment -

          Won't be included in Jenkins 2.387.1 that releases March 8. Likely included in 2.387.2 that will release April 5, 2023.

          Mark Waite added a comment - Won't be included in Jenkins 2.387.1 that releases March 8. Likely included in 2.387.2 that will release April 5, 2023.

            markewaite Mark Waite
            marcodl Marco
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: