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

`Parameterized Remote Trigger Plugin` sometimes fails with poll interval value more than 5 minutes

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • Jenkins version - 2.89.4 (Ubuntu 16.04.5 LTS x64, openjdk version "1.8.0_151")
      Parameterized Remote Trigger Plugin version - 3.0.5

       

      There is a problem when we try to use poll interval parameter's value more than 300 seconds(5 minutes). We have a Jenkins pipeline which may take from 30 to 60 minutes.

      In some cases Jenkins `queued` item may move to the `pending` state as it described here:
      https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/Queue.java#L139

      In such case the plugin use user specified poll interval time out value to check queued item state:

      https://github.com/jenkinsci/parameterized-remote-trigger-plugin/blob/master/src/main/java/org/jenkinsci/plugins/ParameterizedRemoteTrigger/RemoteBuildConfiguration.java#L696

      But all `queued` items in the Jenkins have time to live only 5 minutes as you can see it here:
      https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/Queue.java#L218

      As result we have triggered `build` on the remote Jenkins server but failed build(`Max number of connection retries have been exeeded` error from the plugin) on the main Jenkins server: 

      Triggering parameterized remote job 'http://192.168.200.8:6680/job/RunTests'
       Using job-level defined 'Credentials Authentication' as user '***' (Credentials ID '***')
      Triggering remote job now.
      CSRF protection is enabled on the remote server.
      The remote job is pending. Waiting for next available executor on master.
       Remote job queue number: 124200
      Waiting for remote build to be executed...
      Waiting for 300 seconds until next poll.
      Connection to remote server failed [404], waiting for to retry - 300 seconds until next attempt. URL: http://192.168.200.8:6680//queue/item/124200/api/json/, parameters: 
      Retry attempt #1 out of 5
      Connection to remote server failed [404], waiting for to retry - 300 seconds until next attempt. URL: http://192.168.200.8:6680//queue/item/124200/api/json/, parameters: 
      Retry attempt #2 out of 5
      Connection to remote server failed [404], waiting for to retry - 300 seconds until next attempt. URL: http://192.168.200.8:6680//queue/item/124200/api/json/, parameters: 
      Retry attempt #3 out of 5
      Connection to remote server failed [404], waiting for to retry - 300 seconds until next attempt. URL: http://192.168.200.8:6680//queue/item/124200/api/json/, parameters: 
      Retry attempt #4 out of 5
      Connection to remote server failed [404], waiting for to retry - 300 seconds until next attempt. URL: http://192.168.200.8:6680//queue/item/124200/api/json/, parameters: 
      Retry attempt #5 out of 5
      Max number of connection retries have been exeeded.

       

      From my point of view there is a simple fix: use default value of the poll interval(10 seconds) to check `queued` item state. Because in the `pending` state the `queued` item is staying only for a few seconds: 

       

      int pollIntervalForQueuedItem = this.pollInterval;
      if (pollIntervalForQueuedItem > DEFAULT_POLLINTERVALL) {
       pollIntervalForQueuedItem = DEFAULT_POLLINTERVALL;
      }
      while (buildInfo.isQueued()) {
       context.logger.println("Waiting for " + pollIntervalForQueuedItem + " seconds until next poll.");
       Thread.sleep(pollIntervalForQueuedItem * 1000);
       buildInfo = updateBuildInfo(buildInfo, context);
       handle.setBuildInfo(buildInfo);
      }

       

      i have just created pull request
      https://github.com/lifemanship/Parameterized-Remote-Trigger-Plugin/commit/f65dae8077a0e16b86ce08512cb984a5a879e555 

       

          [JENKINS-55038] `Parameterized Remote Trigger Plugin` sometimes fails with poll interval value more than 5 minutes

          Nick Korsakov created issue -
          Nick Korsakov made changes -
          Description Original:  

          There is a problem when we try to use poll interval parameter's value more than 300 seconds(5 minutes). We have a Jenkins pipeline which may take from 30 to 60 minutes.

          In some cases Jenkins `queued` item may move to the `pending` state as it described here:
          [https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/Queue.java#L139]

          In such case the plugin use user specified poll interval time out value to check queued item state:

          [https://github.com/jenkinsci/parameterized-remote-trigger-plugin/blob/master/src/main/java/org/jenkinsci/plugins/ParameterizedRemoteTrigger/RemoteBuildConfiguration.java#L696]

          But all `queued` items in the Jenkins have time to live only 5 minutes as you can see it here:
          [https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/Queue.java#L218]

          As result we have triggered `build` on the remote Jenkins server but failed build(`Max number of connection retries have been exeeded` error from the plugin) on the main Jenkins server: 
          {code:java}
          Triggering parameterized remote job 'http://192.168.200.8:6680/job/RunTests'
           Using job-level defined 'Credentials Authentication' as user '***' (Credentials ID '***')
          Triggering remote job now.
          CSRF protection is enabled on the remote server.
          The remote job is pending. Waiting for next available executor on master.
           Remote job queue number: 124200
          Waiting for remote build to be executed...
          Waiting for 300 seconds until next poll.
          Connection to remote server failed [404], waiting for to retry - 300 seconds until next attempt. URL: http://192.168.200.8:6680//queue/item/124200/api/json/, parameters:
          Retry attempt #1 out of 5
          Connection to remote server failed [404], waiting for to retry - 300 seconds until next attempt. URL: http://192.168.200.8:6680//queue/item/124200/api/json/, parameters:
          Retry attempt #2 out of 5
          Connection to remote server failed [404], waiting for to retry - 300 seconds until next attempt. URL: http://192.168.200.8:6680//queue/item/124200/api/json/, parameters:
          Retry attempt #3 out of 5
          Connection to remote server failed [404], waiting for to retry - 300 seconds until next attempt. URL: http://192.168.200.8:6680//queue/item/124200/api/json/, parameters:
          Retry attempt #4 out of 5
          Connection to remote server failed [404], waiting for to retry - 300 seconds until next attempt. URL: http://192.168.200.8:6680//queue/item/124200/api/json/, parameters:
          Retry attempt #5 out of 5
          Max number of connection retries have been exeeded.{code}
           

          From my point of view there is a simple fix: use default value of the poll interval(10 seconds) to check `queued` item state. Because in the `pending` state the `queued` item is staying only for a few seconds: 

           
          {code:java}
          int pollIntervalForQueuedItem = this.pollInterval;
          if (pollIntervalForQueuedItem > DEFAULT_POLLINTERVALL) {
           pollIntervalForQueuedItem = DEFAULT_POLLINTERVALL;
          }
          while (buildInfo.isQueued()) {
           context.logger.println("Waiting for " + pollIntervalForQueuedItem + " seconds until next poll.");
           Thread.sleep(pollIntervalForQueuedItem * 1000);
           buildInfo = updateBuildInfo(buildInfo, context);
           handle.setBuildInfo(buildInfo);
          }{code}
           

           

           
          New:  

          There is a problem when we try to use poll interval parameter's value more than 300 seconds(5 minutes). We have a Jenkins pipeline which may take from 30 to 60 minutes.

          In some cases Jenkins `queued` item may move to the `pending` state as it described here:
           [https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/Queue.java#L139]

          In such case the plugin use user specified poll interval time out value to check queued item state:

          [https://github.com/jenkinsci/parameterized-remote-trigger-plugin/blob/master/src/main/java/org/jenkinsci/plugins/ParameterizedRemoteTrigger/RemoteBuildConfiguration.java#L696]

          But all `queued` items in the Jenkins have time to live only 5 minutes as you can see it here:
           [https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/Queue.java#L218]

          As result we have triggered `build` on the remote Jenkins server but failed build(`Max number of connection retries have been exeeded` error from the plugin) on the main Jenkins server: 
          {code:java}
          Triggering parameterized remote job 'http://192.168.200.8:6680/job/RunTests'
           Using job-level defined 'Credentials Authentication' as user '***' (Credentials ID '***')
          Triggering remote job now.
          CSRF protection is enabled on the remote server.
          The remote job is pending. Waiting for next available executor on master.
           Remote job queue number: 124200
          Waiting for remote build to be executed...
          Waiting for 300 seconds until next poll.
          Connection to remote server failed [404], waiting for to retry - 300 seconds until next attempt. URL: http://192.168.200.8:6680//queue/item/124200/api/json/, parameters:
          Retry attempt #1 out of 5
          Connection to remote server failed [404], waiting for to retry - 300 seconds until next attempt. URL: http://192.168.200.8:6680//queue/item/124200/api/json/, parameters:
          Retry attempt #2 out of 5
          Connection to remote server failed [404], waiting for to retry - 300 seconds until next attempt. URL: http://192.168.200.8:6680//queue/item/124200/api/json/, parameters:
          Retry attempt #3 out of 5
          Connection to remote server failed [404], waiting for to retry - 300 seconds until next attempt. URL: http://192.168.200.8:6680//queue/item/124200/api/json/, parameters:
          Retry attempt #4 out of 5
          Connection to remote server failed [404], waiting for to retry - 300 seconds until next attempt. URL: http://192.168.200.8:6680//queue/item/124200/api/json/, parameters:
          Retry attempt #5 out of 5
          Max number of connection retries have been exeeded.{code}
           

          From my point of view there is a simple fix: use default value of the poll interval(10 seconds) to check `queued` item state. Because in the `pending` state the `queued` item is staying only for a few seconds: 

           
          {code:java}
          int pollIntervalForQueuedItem = this.pollInterval;
          if (pollIntervalForQueuedItem > DEFAULT_POLLINTERVALL) {
           pollIntervalForQueuedItem = DEFAULT_POLLINTERVALL;
          }
          while (buildInfo.isQueued()) {
           context.logger.println("Waiting for " + pollIntervalForQueuedItem + " seconds until next poll.");
           Thread.sleep(pollIntervalForQueuedItem * 1000);
           buildInfo = updateBuildInfo(buildInfo, context);
           handle.setBuildInfo(buildInfo);
          }{code}
           

          i have just created pull request
          https://github.com/lifemanship/Parameterized-Remote-Trigger-Plugin/commit/f65dae8077a0e16b86ce08512cb984a5a879e555 

           
          KaiHsiang Chang made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Fixed but Unreleased [ 10203 ]
          KaiHsiang Chang made changes -
          Released As New: https://github.com/jenkinsci/parameterized-remote-trigger-plugin/releases/tag/Parameterized-Remote-Trigger-3.0.7
          Status Original: Fixed but Unreleased [ 10203 ] New: Resolved [ 5 ]
          Nick Korsakov made changes -
          Resolution Original: Fixed [ 1 ]
          Status Original: Resolved [ 5 ] New: Reopened [ 4 ]

            cashlalala KaiHsiang Chang
            lifemanship Nick Korsakov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: