Skip to content

Commit

Permalink
[JENKINS-27329] Less aggressive WorkspaceCleanupThread (#3444)
Browse files Browse the repository at this point in the history
* 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 f258aff
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/src/main/java/hudson/model/WorkspaceCleanupThread.java
Expand Up @@ -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;
}
Expand Down

0 comments on commit f258aff

Please sign in to comment.