Certain conditions might lock more resources than required quantity

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      In strained situations, more resources than you asked for might get locked. This creates a bottleneck problem related to resources but it cannot be solved by adding more resources.

      In worst cases will always lock all resources with a certain label instead of the required amount.

      You can recreate the issue by configuring a couple (say 4) of lockable resources with a tag. Trigger a bunch of these jobs with NUM_RESOURCES between 1 - 4 to build up a queue of jobs waiting for their resources to become available. Eventually the error will start appearing.

      properties([
          parameters ([
              string(name: 'NUM_RESOURCES')
          ])
      ]);
      
      node {
          def askFor = params.NUM_RESOURCES as Integer
          lock(label: "FOO", quantity: askFor) {
              def clients = org.jenkins.plugins.lockableresources.LockableResourcesManager.class.get().getResourcesFromBuild(currentBuild.getRawBuild())
              echo("Asked for ${askFor} resources, got ${clients.size()}: ${clients.toString()}")
              sleep (60 * 10)
              if (askFor != clients.size()) {
                  error ("Wrong amount of resources acquired")
              }
          }
      }
      

            Assignee:
            Unassigned
            Reporter:
            Marcus Antonsson
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Archived: