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

@libs pseudo-workspace collision due to branch name truncation

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      I've spot an issue with unwanted interaction between different, independent jobs.

      Here are the details: Our Jenkins instance (2.176.1 LTS) has some global pipeline libraries configured. My task was some kind of structural migration on a bunch of different projects. So I created a corresponding branch on each of these projects, did the change there and pushed it. So all the build jobs started at the same time and surprisingly most of them failed with a strange error during initial jobs steps like this:

      ...
      remote: Compressing objects: 100% (6/6), done.        
      remote: Total 8 (delta 0), reused 0 (delta 0)        
      error: cannot lock ref 'refs/remotes/origin/bugfix/ESTA-3146-yla': Unable to create '/var/jenkins_home/workspace/rate-build-description-to-json_5@libs/pipeline-helper/.git/refs/remotes/origin/bugfix/ESTA-3146-yla.lock': File exists.
      
      Another git process seems to be running in this repository, e.g.
      ...
      

      After digging around I figured out, that the pipeline helper libs are cloned on the Jenkins master using a folder named like the job a/o branch, which is suffixed with `_<buildnumber>@libs`. Additionally the folder name is stripped to 37 characters by removing characters from the beginning of the name. This leads to the real cause: Because of the identical branch name on each Git repository, the unique part of the folder names got lost and so the jobs try to use the same folder during their initialization steps respectively the cloning of the pipeline helper libs. As soon as the simultaneous running jobs have a differnt build number, it works as expected.

      The branch was named "feature/KIHUB-7882-separate-build-description-to-json" on all modified projects respectively Git repositories and so at the master it looks like this right now:

      $ cd /var/jenkins_home/workspace
      $ ls -1
      ...
      rate-build-description-to-json_2@libs
      rate-build-description-to-json_3@libs
      rate-build-description-to-json_4@libs
      rate-build-description-to-json_5@libs
      rate-build-description-to-json_6@libs
      rate-build-description-to-json_7@libs
      rate-build-description-to-json_8@libs
      rate-build-description-to-json_9@libs
      ...
      $
      

      So for me there are two questions and two possible solutions:
      1. Why is the folder name stripped?
      2. Why is the folder structure "flat" at this point and not like on the build jobs themself?

      I think there should be at least one folder level in between like this pseudo code example:

      /var/jenkins_home/workspace/OrgaScannerA/JobA-A/rate-build-description-to-json_3@libs
      /var/jenkins_home/workspace/OrgaScannerA/JobA-B/rate-build-description-to-json_3@libs
      /var/jenkins_home/workspace/OrgaScannerB/JobB-A/rate-build-description-to-json_3@libs
      /var/jenkins_home/workspace/OrgaScannerB/JobB-B/rate-build-description-to-json_3@libs
      

      Or the folder name itself should be unique:

      /var/jenkins_home/workspace/OrgaScannerA-JobA-A-rate-build-description-to-json_3@libs
      /var/jenkins_home/workspace/OrgaScannerA-JobA-B-rate-build-description-to-json_3@libs
      /var/jenkins_home/workspace/OrgaScannerB-JobB-A-rate-build-description-to-json_3@libs
      /var/jenkins_home/workspace/OrgaScannerB-JobB-B-rate-build-description-to-json_3@libs
      

        Attachments

          Issue Links

            Activity

            swf Yves Schumann created issue -
            smasher Daniel Estermann made changes -
            Field Original Value New Value
            Assignee Daniel Estermann [ smasher ]
            smasher Daniel Estermann made changes -
            Assignee Daniel Estermann [ smasher ]
            Hide
            swf Yves Schumann added a comment -

            Any news here? Spot the same issue again...

            Show
            swf Yves Schumann added a comment - Any news here? Spot the same issue again...
            smasher Daniel Estermann made changes -
            Assignee Daniel Estermann [ smasher ]
            Hide
            smasher Daniel Estermann added a comment -

            Tried to reproduce. Unsuccessfully so far...

            Show
            smasher Daniel Estermann added a comment - Tried to reproduce. Unsuccessfully so far...
            Hide
            smasher Daniel Estermann added a comment -

            I managed to reproduce it, for that purpose I had to set workspaceDir in $JENKINS_HOME/config.xml to the recommended value ${JENKINS_HOME}/workspace/${ITEM_FULL_NAME} (as in WorkspaceLocatorImpl.java:337). Hence this is related to path sanitization.

            Show
            smasher Daniel Estermann added a comment - I managed to reproduce it, for that purpose I had to set workspaceDir in $JENKINS_HOME/config.xml to the recommended value ${JENKINS_HOME}/workspace/${ITEM_FULL_NAME } (as in WorkspaceLocatorImpl.java:337 ). Hence this is related to path sanitization.
            smasher Daniel Estermann made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            smasher Daniel Estermann made changes -
            Link This issue is related to JENKINS-2111 [ JENKINS-2111 ]
            smasher Daniel Estermann made changes -
            Link This issue is related to JENKINS-21942 [ JENKINS-21942 ]
            jglick Jesse Glick made changes -
            Component/s branch-api-plugin [ 18621 ]
            Component/s workflow-cps-global-lib-plugin [ 21714 ]
            Component/s core [ 15593 ]
            Component/s pipeline [ 21692 ]
            Hide
            jglick Jesse Glick added a comment -

            try -Djenkins.branch.WorkspaceLocatorImpl.MODE=ENABLED

            Show
            jglick Jesse Glick added a comment - try -Djenkins.branch.WorkspaceLocatorImpl.MODE=ENABLED
            jglick Jesse Glick made changes -
            Summary Unwanted job interaction if using global pipeline libraries @libs pseudo-workspace collision due to branch name truncation
            smasher Daniel Estermann made changes -
            Attachment screenshot-1.png [ 51067 ]
            smasher Daniel Estermann made changes -
            Attachment screenshot-2.png [ 51068 ]
            Hide
            smasher Daniel Estermann added a comment - - edited

            It doesn't seem to change anything, the folder names in ${JENKINS_HOME}/workspace look the same to me:

            Without -Djenkins.branch.WorkspaceLocatorImpl.MODE=ENABLED

            With -Djenkins.branch.WorkspaceLocatorImpl.MODE=ENABLED

            Yves Schumann What do you think?

            Show
            smasher Daniel Estermann added a comment - - edited It doesn't seem to change anything, the folder names in ${JENKINS_HOME}/workspace look the same to me: Without -Djenkins.branch.WorkspaceLocatorImpl.MODE=ENABLED With -Djenkins.branch.WorkspaceLocatorImpl.MODE=ENABLED Yves Schumann What do you think?
            Hide
            swf Yves Schumann added a comment -

            Jesse Glick: What functionality is enabled, if this option is used?

            Show
            swf Yves Schumann added a comment - Jesse Glick : What functionality is enabled, if this option is used?
            Hide
            jglick Jesse Glick added a comment -

            The workspace management system introduced in JENKINS-2111 is enabled for all projects, not merely multibranch. I had thought this would affect the pseudo-workspaces used by workflow-cps-global-lib, but on closer inspection that seems to not be the issue. Possibly a bug in WorkspaceLocatorImpl. Would need to dig into a reproduction test case. Is /var/jenkins_home/workspace/workspaces.txt not tracking the various branch projects?

            Show
            jglick Jesse Glick added a comment - The workspace management system introduced in JENKINS-2111 is enabled for all projects, not merely multibranch. I had thought this would affect the pseudo-workspaces used by workflow-cps-global-lib , but on closer inspection that seems to not be the issue. Possibly a bug in WorkspaceLocatorImpl . Would need to dig into a reproduction test case. Is /var/jenkins_home/workspace/workspaces.txt not tracking the various branch projects?
            Hide
            smasher Daniel Estermann added a comment - - edited

            I've just checked /var/jenkins_home/workspace/workspaces.txt on my test instance. It contains indeed the following entries:

            <path_to_project>/<branch>
            <folder>
            

            But IMHO it doesn't help against different jobs working on the same git folder.

            Show
            smasher Daniel Estermann added a comment - - edited I've just checked /var/jenkins_home/workspace/workspaces.txt on my test instance. It contains indeed the following entries: <path_to_project>/<branch> <folder> But IMHO it doesn't help against different jobs working on the same git folder.
            Hide
            jglick Jesse Glick added a comment -

            Not sure offhand. Bug somewhere.

            Show
            jglick Jesse Glick added a comment - Not sure offhand. Bug somewhere.
            Hide
            smasher Daniel Estermann added a comment -

            Jesse Glick May I hand over this issue to you?

            Show
            smasher Daniel Estermann added a comment - Jesse Glick May I hand over this issue to you?
            Hide
            jglick Jesse Glick added a comment -

            No, I am not maintaining these plugins, sorry.

            Show
            jglick Jesse Glick added a comment - No, I am not maintaining these plugins, sorry.

              People

              Assignee:
              smasher Daniel Estermann
              Reporter:
              swf Yves Schumann
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated: