Issue
After upgrading a Jenkins controller, the web UI displays the "Please wait while Jenkins is getting ready to work" message for an unusually long period of time. In the service logs you see a continual stream of entries like this:
22-Nov-2020 13:20:03.008 INFO [Jenkins initialization thread] jenkins.model.Jenkins.<init> deleting obsolete workspace /jenkins_home/workspace/my-sample-project
Resolution
This issue can occur when Jenkins tries to clean up old workspaces for jobs and branches that no longer exist. In cases where the workspace directory is very large (hundreds of GB) and/or storage performance is slow, this cleanup can take an extremely long time, and the service startup is blocked until the cleanup finishes. The workspace directory is used as a cache of SCM repositories that have been checked out previously, to help speed up builds by avoiding the need to clone the entire repo again.
Workaround
Because the workspace directory is only a cache, it is safe to delete it if the obsolete workspace cleanup process is preventing your controller from starting up in a timely way. The workaround steps are as follows:
-
Stop the controller service.
-
Rename
JENKINS_HOME/workspace
andJENKINS_HOME/cache
to e.g.workspace.old
andcache.old
. -
Start the controller service again.
-
Once service is restored, you can delete the
workspace.old
andcache.old
directories if you wish (this is advisable as otherwise they may waste significant disk space.