Actually the WorkspaceClleanerThread is supposed to cleanup the suffixed directories since the fix for https://issues.jenkins.io/browse/JENKINS-41805 but this is not happening for @libs suffixed workspaces on the controller for builds that are executed on non-controller executors. cc timja
In those cases, there is only a @libs suffixed workspace but not the original and we don'tpass the condition https://github.com/jenkinsci/jenkins/blob/jenkins-2.447/core/src/main/java/hudson/model/WorkspaceCleanupThread.java#L107.
In such case, the WorkspaceLocator finds out that there is a workspace on the controller FS, but it looks for existence of $WORKSPACE and not $WORKSPACE@libs.
Here is an example of a job built by test agent test-agent that use a shared library. The library is cloned under /var/jenkins_home/workspace/pipelines/pipelineFromScriptWithLib@libs but there is no /var/jenkins_home/workspace/pipelines/pipelineFromScriptWithLib:
Mar. 05, 2024 1:12:03 PM FINE jenkins.branch.WorkspaceLocatorImpl locate
ignoring non-branch project org.jenkinsci.plugins.workflow.job.WorkflowJob@1744e0b[pipelines/pipelineFromScriptWithLib] on hudson.model.Hudson@5787278d
Mar. 05, 2024 1:12:03 PM FINE hudson.model.WorkspaceCleanupThread shouldBeDeleted
Directory /var/jenkins_home/workspace/pipelines/pipelineFromScriptWithLib does not exist
Here is another example with a branch jobs, the library is cloned under /var/jenkins_home/workspace/_catalog-poc-pipelines_withLib_2@libs but there is no /var/jenkins_home/workspace/_catalog-poc-pipelines_withLib_2:
Mar. 05, 2024 1:12:03 PM FINER jenkins.branch.WorkspaceLocatorImpl locate
index already lists /var/jenkins_home/workspace/_catalog-poc-pipelines_withLib_2 for org.jenkinsci.plugins.workflow.job.WorkflowJob@21ed6f70[organizations/organizationGithubScm/ci-catalog-poc-pipelines/withLib] on hudson.model.Hudson@5787278d
Mar. 05, 2024 1:12:03 PM FINE hudson.model.WorkspaceCleanupThread shouldBeDeleted
Directory /var/jenkins_home/workspace/_catalog-poc-pipelines_withLib_2 does not exist
To reproduce:
- start Jenkins with -Dhudson.model.WorkspaceCleanupThread.retainForDays=0
- Set up a remote agent
- Create a pipeline that clones a library:
@Library("testLibs") _
node ('test') {
echo "test"
}
- Build the job
- Run hudson.model.AsyncPeriodicWork.all().get(WorkspaceCleanupThread.class).run() in the script console to execute the thread run
same issue here, i have just cleanup 30Go of remaining @libs directories ...