p4 workspace marked as "stale" and deleted after a week
I've encountered the following problem. When a p4 workspace on a build agent is not used for a week, it gets deleted by TeamCity. The following appears in the teamcity-agent.log
INFO - l.directories.DirectoryMapImpl - Delete <CheckoutDirectory>. Build directory has expired or unused
WARN - jetbrains.buildServer.VCS.P4 - Stale workspace detected: <Workspace>, last access: Mon Apr 18 00:00:00 BST 2011, stale msecs: 604800000
In our project, we do not want this behavior - we explicitly want the project checkout directory to stay on the agent, even if no build has taken place for a week (or more). Could you please advise where is this setting configured or how this behavior can be changed?
Please note that this seems to start occurring after our upgrade to TeamCity Enterprise Version6.5 EAP (build 17521) from a previous version.
Thanks
Please sign in to leave a comment.
Hello Petr,
You can completely disable cleanup of the workspace if you pass system property to the build agent:
-Dteamcity.perforce.workspace.cleanup=false
You can specify number of days within which stale workspaces won't be deleted:
-Dteamcity.perforce.workspace.cleanup.period.days=30
Note: you have to pass these parameters as the build agent startup system properties, as described here.
Hope, this helps,
KIR
Hi Kirill,
Is there also an option to force the workspace to get cleaned-up (deleted) even if it has files checked out?
Thanks,
Delfino
Hi Delfino,
Actually, the workspace should be deleted even in that case.
Please provide buildAgent/logs/teamcity-vcs.log if this doesn't work.
Regards,
KIR
Updating sources: agent side checkout...
[01:35:05]: [Updating sources: agent side checkout...] Failed to perform checkout on agent: Client 'TC_p4_SANDBOX3_e12a8ef54557331e_b632be9a59ff76f0' has files opened; use -f to force delete. jetbrains.buildServer.vcs.VcsException: Client 'TC_p4_SANDBOX3_e12a8ef54557331e_b632be9a59ff76f0' has files opened; use -f to force delete. at jetbrains.buildServer.vcs.perforce.PerforceConnection.runCommand(PerforceConnection.java:304) at jetbrains.buildServer.vcs.perforce.PerforceConnection.runCommand(PerforceConnection.java:342) at jetbrains.buildServer.vcs.perforce.PerforceConnection.deleteWorkspace(PerforceConnection.java:800) at jetbrains.buildServer.vcs.perforce.PerforceConnection.runClientListCommandWithCleanup(PerforceConnection.java:768) at jetbrains.buildServer.vcs.perforce.PerforceConnection.removeOldTeamCityWorkspaces(PerforceConnection.java:747) at jetbrains.buildServer.vcs.perforce.PerforceSourceUpdater.updateSources(PerforceSourceUpdater.java:60) at jetbrains.buildServer.vcs.perforce.PerforceSourceUpdater.updatePerforceSources(PerforceSourceUpdater.java:47)
-------
The vcs log says WARN - jetbrains.buildServer.VCS.P4 - Deleting stale workspace TC_p4_SANDBOX3_e12a8ef54557331e_b632be9a59ff76f0 .
------
So it does attempt to delete the workspace, but it fails since it has files checked out.
Thanks.
Hello,
I've filed an issue for the problem, thanks!
http://youtrack.jetbrains.net/issue/TW-17334
Please watch.
Regards,
KIR
Hi Kirill,
I've tried setting the enviornment variable:
TEAMCITY_AGENT_OPTS=-Dteamcity.perforce.workspace.cleanup=false -Dteamcity.perforce.workspace.cleanup.period.days=3000
And restarted the build agent.
But it is still trying to clear stale workspaces, am i setting the variable and passing it correctly? We are running the build agent from the agent.bat file.
Thanks.
Hello Delfino,
If you use agent.bat file, the syntax
SET TEAMCITY_AGENT_OPTS=-Dteamcity.perforce.workspace.cleanup.period.days=3000
should work.
Also, are sure your agent is started not as a Windows service? In this case this sutuation is different.
Also, which version of TeamCity do you use?
Regards,
KIR