|
I think there is a bug in the workspace cleanup code. We've been battling with disappearing workspaces and I could not figure out what was happening until I stumbled upon this thread. In our case, I moved a job from one slave to a different slave, but the cleanup code seemed to think it was ok to delete based on the old slave. The message in the log was Deleting <dir> on <old slave name> We haven't been using that old slave for this job for at least a few weeks. To make matters worse, it deleted the workspace WHILE the job was running on the new slave. This appears to be the trouble code:
for (Node node : nodes) {
FilePath ws = node.getWorkspaceFor(item);
if (ws == null) { bq. continue; // offline, fine bq. }
boolean check;
try {
check = shouldBeDeleted(item, ws, node);
The first node that it comes across that returns shouldBeDeleted true causes the workspace deleted even if another node (later in the list) is the last builder of that job (meaning the job is still active). This tries to get caught in shouldBeDeleted()
Node lb = p.getLastBuiltOn();
LOGGER.log(Level.FINER, "Directory {0} is last built on {1}", new Object[] {dir, lb}); bq. if(lb!=null && lb.equals ) { bq. // this is the active workspace. keep it. bq. LOGGER.log(Level.FINE, "Directory {0} is the last workspace for {1}", new Object[] {dir, p});
return false;
}
But since the for loop code takes action before checking all nodes, this check can be pointless.
|