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

"DELETE generated files" doesnt always work when parralel jobs run

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • p4-plugin
    • None

      Create pipeline job that uses following Jenkinsfile via "Pipeline script from SCM":

      pipeline {
        agent { label 'master' }
        stages {
          stage("Repro") {
            steps {
              script {
                sh "pwd"
                sh "ls -l"
                sh "if [ -e this_should_be_cleaned_up ]; then false; else true; fi"
                input(message: "Fake input to reproduce, please DO NOT proceed, just start another build of this job",
                  parameters: [booleanParam(defaultValue: false, description: "", name: "Mocked choice")])
                sh "touch this_should_be_cleaned_up"
              }
            }
          }
        }
      }
      
      

      Perform following test:

      1. Start job, wait until it asks for input, DO NOT PROCEED
      2. Start the job again, it will go to input stage
      3. Proceed on both builds (by entering text in console)
      4. Start job again, wait until it asks for input, DO NOT PROCEED
      5. Start the job again it will immediately FAIL, because file "~jenkins/workspace/JOB_NAME@2/this_should_be_cleaned_up" was not deleted during the checkout stage

      From now on, you can repeat steps 4 and 5, it will reproduce every time.

       

      Different workspaces are used for the parallel jobs but 'JOB_NAME@2' is not cleaned up in this scenario.

          [JENKINS-45339] "DELETE generated files" doesnt always work when parralel jobs run

          Code changed in jenkins
          User: Paul Allen
          Path:
          src/main/java/org/jenkinsci/plugins/p4/client/ClientHelper.java
          http://jenkins-ci.org/commit/p4-plugin/9dd03e221cf9556f6cf942fd15b055c07ef366bd
          Log:
          Use Decoded URL path for local delete.

          Local client syntax uses URL @ encoding, but the local filesystem needs
          the decoded path. JENKINS-45339

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Paul Allen Path: src/main/java/org/jenkinsci/plugins/p4/client/ClientHelper.java http://jenkins-ci.org/commit/p4-plugin/9dd03e221cf9556f6cf942fd15b055c07ef366bd Log: Use Decoded URL path for local delete. Local client syntax uses URL @ encoding, but the local filesystem needs the decoded path. JENKINS-45339

          Mirek Sz added a comment -

          The issue still persist in 1.7.2 and 1.7.3.

          Mirek Sz added a comment - The issue still persist in 1.7.2 and 1.7.3.

          Mirek Sz added a comment -

          The issue may be due to the same client name trying to be reused for another client root directory (one is /var/lib/jenkins/workspace/job_name another /var/lib/jenkins/workspace/job_name@2). Jenkins by default uses "jenkins-${NODE_NAME}-${JOB_NAME}" as workspace name and AFAIK perforce cannot use it for both directories.

          FYI: Trying to use ${EXECUTOR_NUMBER} in "Workspace name" and mapping doesn't help - the value of this is not resolved by jenkins when it comes to p4 commands.

          I think P4 plugin creates "jenkins-${NODE_NAME}-${JOB_NAME}.clone2" client to solve that issue, maybe the feature is not working correctly?

          Mirek Sz added a comment - The issue may be due to the same client name trying to be reused for another client root directory (one is /var/lib/jenkins/workspace/job_name another /var/lib/jenkins/workspace/job_name@2). Jenkins by default uses "jenkins-${NODE_NAME}-${JOB_NAME}" as workspace name and AFAIK perforce cannot use it for both directories. FYI: Trying to use ${EXECUTOR_NUMBER} in "Workspace name" and mapping doesn't help - the value of this is not resolved by jenkins when it comes to p4 commands. I think P4 plugin creates "jenkins-${NODE_NAME}-${JOB_NAME}.clone2" client to solve that issue, maybe the feature is not working correctly?

          Paul Allen added a comment -

          I have reproduced this with the Pipeline Script:

          node() {
          writeFile file: 'del1', text: 'content'
          
          p4sync charset: 'none', 
          credential: 'phooey', 
          populate: autoClean(delete: true, modtime: false, quiet: true, replace: true, tidy: false), 
          source: depotSource('//depot/Main/...')
          
          sleep 10
          }

          The error might be in ClientHelper.depotToLocal(), I'll do some more digging.

          Paul Allen added a comment - I have reproduced this with the Pipeline Script: node() { writeFile file: 'del1' , text: 'content' p4sync charset: 'none' , credential: 'phooey' , populate: autoClean(delete: true , modtime: false , quiet: true , replace: true , tidy: false ), source: depotSource( ' //depot/Main/...' ) sleep 10 } The error might be in ClientHelper.depotToLocal(), I'll do some more digging.

          Karl Wirth added a comment -

          Worked with p4paul and this looks like a P4D server behavior when '@' is in the workspace root folder name. Raised to P4D developers.

          Karl Wirth added a comment - Worked with p4paul and this looks like a P4D server behavior when '@' is in the workspace root folder name. Raised to P4D developers.

          Paul Allen added a comment -

          There is no code workaround for the p4-plugin, we will have to see what the P4D team suggest.  The only generic workaround is to prevent Jenkins using the '@' symbol, by setting the JVM option at startup:

          -Dhudson.slaves.WorkspaceList="_"

          Where '_' is used instead.

          Paul Allen added a comment - There is no code workaround for the p4-plugin, we will have to see what the P4D team suggest.  The only generic workaround is to prevent Jenkins using the '@' symbol, by setting the JVM option at startup: -Dhudson.slaves.WorkspaceList= "_" Where '_' is used instead.

          Paul Allen added a comment -

          Fixed around 1.8.2 by changing clone behaviour for concurrent builds.

          Paul Allen added a comment - Fixed around 1.8.2 by changing clone behaviour for concurrent builds.

            p4karl Karl Wirth
            p4karl Karl Wirth
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: