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

Lockable Resource Plugin returns null resource after saving system configuration

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Labels:
      None
    • Environment:
    • Similar Issues:

      Description

      The lock step can obtain a null resource after saving a global system configuration by clicking on "Manage Jenkins" -> "Configure System" -> "Save".  The bug occurs irregardless of any actual changes has been made.

      steps to reproduce

      setup

      • 4 jobs with the following configuration:
        node {
            boolean retry = true;
            while (retry) {
                lock(label: 'res1', quantity: 1, variable: 'RES_NAME') {
                    println env.RES_NAME
                    if ("${env.RES_NAME}" != "null") {
                        retry = false;
                        sleep(100)
                    }
                }
            }
        }
      • 2 resources configured "r1" and "r2", both with label "res1"
      • 4 executors.

      Steps

      1. Activate a build for each of the jobs simultaneously. 2 of the builds will obtain a lock and then proceed to sleep.  2 of the builds will be blocked waiting for a resource.
      2. Update the system configuration by clicking on "Manage Jenkins" -> "Configure System" -> "Save"
      3. One of the blocked build will obtain a "null" resource and re-trying a lock will obtain a resource that is already being used by one of the sleeping build. Demonstrated by the following snippet of the console output:
       Running on Jenkins in /var/jenkins_home/workspace/test4@2
      [Pipeline] {
      [Pipeline] lock
      Trying to acquire lock on [Label: res1, Quantity: 1]
      Found 0 available resource(s). Waiting for correct amount: 1.
      [Label: res1, Quantity: 1] is locked, waiting...
      Lock acquired on [Label: res1, Quantity: 1]
      [Pipeline] {
      [Pipeline] echo
      null
      [Pipeline] }
      Lock released on resource [Label: res1, Quantity: 1]
      [Pipeline] // lock
      [Pipeline] lock
      Trying to acquire lock on [Label: res1, Quantity: 1]
      Lock acquired on [Label: res1, Quantity: 1]
      [Pipeline] {
      [Pipeline] echo
      r1
      [Pipeline] sleep
      Sleeping for 1 min 40 sec[Pipeline] }
      Lock released on resource [Label: res1, Quantity: 1]
      [Pipeline] // lock
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline

        Attachments

          Activity

          Hide
          fkykko Staffan Forsell added a comment -

          Just hit this issue and I raised the priority.

          This is a bug that wastes a lot of time for someone trying to debug broken build scripts, when it's actually not a broken at all.

          Show
          fkykko Staffan Forsell added a comment - Just hit this issue and I raised the priority. This is a bug that wastes a lot of time for someone trying to debug broken build scripts, when it's actually not a broken at all.
          Hide
          duael Emmanuel Ruhnau added a comment -

          Seems to happens also when a job is waiting in queue and someone goes to the lockable resource page to reserve or unreserve a station. The queued job will then get a "null" resource when it will run.

          Show
          duael Emmanuel Ruhnau added a comment - Seems to happens also when a job is waiting in queue and someone goes to the lockable resource page to reserve or unreserve a station. The queued job will then get a "null" resource when it will run.

            People

            • Assignee:
              Unassigned
              Reporter:
              scott_zhong Scott Zhong
            • Votes:
              4 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: