Race-condition when checking out global library

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

XMLWordPrintable

      It seems like PR:18 introduced a race-condition when you have several builds of the same job starting at the same time.
      Looking at the code in the pull request:

      try (WorkspaceList.Lease lease = computer.getWorkspaceList().allocate(dir)) {
          delegate.checkout(run, dir, listener, node.createLauncher(listener));
          // Cannot add WorkspaceActionImpl to private CpsFlowExecution.flowStartNodeActions; do we care?
          // Copy sources with relevant files from the checkout:
          dir.copyRecursiveTo("src/**/*.groovy,vars/*.groovy,vars/*.txt,resources/", null, target);
      }
      

      We changed from using acquire to using allocate, which is non-blocking and instead append a suffix to the path if needed. The only problem with the change is that we still use the base directory given to allocate and ignoring the fact that we might have allocated another directory. Instead we should use lease.path, which is what we actually leased!

      So the code should probably be in the lines of:

      try (WorkspaceList.Lease lease = computer.getWorkspaceList().allocate(dir)) {
          delegate.checkout(run, lease.path, listener, node.createLauncher(listener));
          // Cannot add WorkspaceActionImpl to private CpsFlowExecution.flowStartNodeActions; do we care?
          // Copy sources with relevant files from the checkout:
          lease.path.copyRecursiveTo("src/**/*.groovy,vars/*.groovy,vars/*.txt,resources/", null, target);
      }
      

            Assignee:
            Jon Sten
            Reporter:
            Jon Sten
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: