Skip to content
Permalink
Browse files

[JENKINS-27329] Less aggressive WorkspaceCleanupThread (#3444)

* JENKINS-27329 Less aggressive WorkspaceCleanupThread

I dare to claim that the default behaviour of WorkspaceCleanupThread is too aggressive => this little change is by no means perfect (or admittedly even far from perfect), but IMHO a saner or slightly more defensive default behaviour.

Mind that according to https://github.com/jenkinsci/jenkins/blob/9e64bcdcb4a2cf12d59dfa334e09ffb448d361e9/core/src/main/java/hudson/model/Job.java#L301 this "only" checks whether or not the last build of a job is in progress, while the JavaDoc says "Returns true if a build of this project is in progress." (cf. http://javadoc.jenkins-ci.org/hudson/model/Job.html#isBuilding--)

* Fix compilation

* Dummy commit to trigger pipeline

Previous pipeline execution (https://ci.jenkins.io/blue/organizations/jenkins/Core%2Fjenkins/detail/PR-3444/2/tests) failed with one failing test that at first glance appears to be unrelated with my change(s) and looks like a flaky test?

* Add fine logging message
  • Loading branch information...
reinholdfuereder authored and oleg-nenashev committed May 26, 2018
1 parent ccd6455 commit f258aff7a736a81306ecb7d3c56cacc9b3a09a68
Showing with 9 additions and 0 deletions.
  1. +9 −0 core/src/main/java/hudson/model/WorkspaceCleanupThread.java
@@ -139,6 +139,15 @@ private boolean shouldBeDeleted(@Nonnull TopLevelItem item, FilePath dir, @Nonnu
}
}

// TODO this may only check the last build in fact:
if (item instanceof Job<?,?>) {
Job<?,?> j = (Job<?,?>) item;
if (j.isBuilding()) {
LOGGER.log(Level.FINE, "Job {0} is building, so not deleting", item.getFullDisplayName());
return false;
}
}

LOGGER.log(Level.FINER, "Going to delete directory {0}", dir);
return true;
}

0 comments on commit f258aff

Please sign in to comment.
You can’t perform that action at this time.