donquijote
donquijote

Reputation: 1812

VSTS Hosted Agent, not enough space in the disk

I cannot build in VSTS with hosted agent (VS 2017) with error:

System.IO.IOException: There is not enough space on the disk

I have tried setting "Clean" option to true on Build , Repository definition without solving the issue. I didn't have this option set to true which I imagine led to the current situation.

Also installed VSTS extension "Clean Agent Directories" and added as last step of the build process without solving the issue either.

Is there an option that would allow me to solve this issue and continue using the hosted build agent ?

Upvotes: 10

Views: 22115

Answers (4)

Dave Higgins
Dave Higgins

Reputation: 243

For now, I'm freeing up ~ 20gb with this insanity:

df -h
echo now freeing disk space
sudo rm -rf /usr/local/lib/android # android sdks
sudo rm -rf /usr/local/.ghcup # haskell stuff
sudo rm -rf /opt/hostedtoolcache/CodeQL # github code analysis engine
echo freed up space:
df -h

Mostly coming from the multitude of android sdk versions.

Upvotes: 4

markwilde
markwilde

Reputation: 1997

There is a trick to free agent space by removing the cached docker images (if you don't need them of course). With the Microsoft hosted agent there is a list of docker images pre-provisioned. This SO answer describes where to find the docs on the different images / cached container images.

It's as simple as adding an extra command task to cleanup the cached images. For Linux / Ubuntu:

steps:
- script: |
  df -h
- script: |
    docker rmi -f $(docker images -aq)
- script: |
    df -h

The df (disk-free) command shows you how much is saved. This will probably free up another 5Gb.

Upvotes: 3

Ulysses Alves
Ulysses Alves

Reputation: 2469

According to Microsoft's documentation,

(Microsoft-hosted agents) Provide at least 10 GB of storage for your source and build outputs.

So, if you are getting "not enough space in disk error" it might mean that the amount of disk space used by your source code (files, repos, branches, etc), together with the amount of disk space taken by your build output (files generated as a result of the build process) is crossing the 10 GB of storaged provided by your DevOps plan.

When getting this error I had to delete an old git repo and an old git branch, getting 17 MB of free space, which was enough for my build to process. Thus, in my case the space was being used up by source code. It could well be too many or too big files being generated by the build. That is, you just need to find out which one of these two is the cause of your lack of disk space, and work on freeing it.

Upvotes: 2

Daniel Mann
Daniel Mann

Reputation: 59016

Hosted agents offer 10 GB of space. You stated that your entire solution folder is 2.6 GB. Your build outputs will typically be somewhere in the range of 2x that size, if not larger, depending on various factors.

If you're a Git user, this the entire repo that's being cloned may be significantly larger than 2.6 GB, as well -- cloning the repo brings down not only the current working copy of the code, but also all of the history.

You can control the clone depth (e.g. how much history is pulled down) by enabling Shallow fetch under the Advanced options of your repo settings.

If you're a TFVC user, you can check your workspace mappings to ensure only relevant source code is being pulled down.

You may be in a situation where the 10 GB simply isn't sufficient for your purposes. If the 2.6 GB is purely code and contains no binary assets (images, PDFs, video files, etc), you may want to start modularizing your application so smaller subsections can be built and independently deployed. If the 2.6 GB contains a lot of binary assets, you'll likely want to separate static content (images, et al) from source code and devise a separate static content deployment process.

Upvotes: 11

Related Questions