actions / runner-images

GitHub Actions runner images
MIT License
10.12k stars 3.05k forks source link

"You are running out of disk space" Error. How can I fix this? #2840

Closed jessehui closed 3 years ago

jessehui commented 3 years ago

Description
The previous execution of this action never gives an error like this. 截屏2021-03-04 下午5 48 22

I think the reason is that the virtual environment is changed. But I am not sure. My question is whether there is a fix for this? I don't want to change the yaml file. Thank you. The action can be found here: https://github.com/occlum/occlum/actions/runs/619537350

Virtual environments affected

Image version

Image version where you are experiencing the issue. Environment: ubuntu-18.04 Version: 20210219.1

al-cheb commented 3 years ago

Hello, @jessehui Based on documentation, we provide at least 14 GB of free space (https://docs.github.com/en/actions/reference/specifications-for-github-hosted-runners#supported-runners-and-hardware-resources).

As a workaround:

sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
jessehui commented 3 years ago

@al-cheb Thank you for your reply. I would give it a try. I am just curious whether this limitation is added recently? Because we never encounter this error running the same workflow before.

arroyc commented 3 years ago

@al-cheb is there any way that you can provide more disk space to the customer? we do multistage docker build and 14 gb is too small for us, we are using 'ubuntu-latest' ado / azure pipelines .. not github actions

Error processing tar file(exit status 1): write /opt/dotnet/3.1.405/packs/Microsoft.NETCore.App.Ref/3.1.0/ref/netcoreapp3.1/System.Resources.ResourceManager.dll: no space left on device

maxim-lobanov commented 3 years ago

@jessehui , this limitation has always existed but previously, we have provided a bit more free space. Sometimes, image can have ~15-20 GB of free space and this volume can be changed without notice. We only guarantee that images contain at least 14 GB of free space.

@arroyc , unfortunately, no. Only workarounds that Aleks has shared above

arroyc commented 3 years ago

@maxim-lobanov thanks for responding ... i just found following information in one of our builds ... its not even 14G ... its less than 10GB .. can you please confirm that? I'm assuming we are only using /dev/sda1

2021-03-05T17:45:05.3501527Z Filesystem Size Used Avail Use% Mounted on 2021-03-05T17:45:05.3506978Z /dev/root 84G 34G 50G 40% / 2021-03-05T17:45:05.3508722Z devtmpfs 3.4G 0 3.4G 0% /dev 2021-03-05T17:45:05.3510122Z tmpfs 3.4G 12K 3.4G 1% /dev/shm 2021-03-05T17:45:05.3511897Z tmpfs 696M 1.1M 695M 1% /run 2021-03-05T17:45:05.3513269Z tmpfs 5.0M 0 5.0M 0% /run/lock 2021-03-05T17:45:05.3515129Z tmpfs 3.4G 0 3.4G 0% /sys/fs/cgroup 2021-03-05T17:45:05.3516728Z /dev/loop0 139M 139M 0 100% /snap/chromium/1506 2021-03-05T17:45:05.3517833Z /dev/loop1 138M 138M 0 100% /snap/chromium/1497 2021-03-05T17:45:05.3518877Z /dev/loop2 56M 56M 0 100% /snap/core18/1988 2021-03-05T17:45:05.3520991Z /dev/loop3 163M 163M 0 100% /snap/gnome-3-28-1804/145 2021-03-05T17:45:05.3522240Z /dev/loop4 32M 32M 0 100% /snap/snapd/11036 2021-03-05T17:45:05.3523353Z /dev/sdb15 105M 7.8M 97M 8% /boot/efi 2021-03-05T17:45:05.3524425Z /dev/loop5 70M 70M 0 100% /snap/lxd/19188 2021-03-05T17:45:05.3525988Z /dev/loop6 65M 65M 0 100% /snap/gtk-common-themes/1514 2021-03-05T17:45:05.3526844Z /dev/loop7 33M 33M 0 100% /snap/snapd/11107 2021-03-05T17:45:05.3527413Z /dev/sda1 14G 4.1G 9.0G 32% /mnt

jessehui commented 3 years ago

@al-cheb @maxim-lobanov Thank you for your help. We've managed to work this out. You may close this issue.

deniscostadsc commented 3 years ago

Hi, @al-cheb.

I'm seeing a similar problem. Is it related to this issue or should I open a new issue. To solve my problem I just rolled back from 20.04 to 18.04, but I was wondering if this is important enough to report.

miketimofeev commented 3 years ago

Hi @deniscostadsc! The image has 14Gb free space as it's described in the documentation https://docs.github.com/en/actions/reference/specifications-for-github-hosted-runners#supported-runners-and-hardware-resources Please consider removing one or all of these directories if you don't need these tools:

sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
asset-web commented 2 years ago

Thanks for the tip @al-cheb

FYI: On ubuntu-20.04 based GitHub actions the below directories exist and removal can free up approx 10G.

sudo rm -rf /usr/share/dotnet sudo rm -rf "$AGENT_TOOLSDIRECTORY"

jfoclpf commented 1 year ago

Just my 5 cents:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - 
        name: Free disk space
        run: |
          sudo docker rmi $(docker image ls -aq) || true
          sudo swapoff /swapfile || true
          sudo rm -rf /swapfile /usr/share/dotnet /usr/local/lib/android /opt/ghc  || true
          sudo apt purge aria2 ansible azure-cli shellcheck rpm xorriso zsync \
            clang-6.0 lldb-6.0 lld-6.0 clang-format-6.0 clang-8 lldb-8 lld-8 clang-format-8 \
            clang-9 lldb-9 lld-9 clangd-9 clang-format-9 dotnet-sdk-3.0 dotnet-sdk-3.1=3.1.101-1 \
            esl-erlang firefox g++-8 g++-9 gfortran-8 gfortran-9 google-chrome-stable \
            google-cloud-sdk ghc-8.0.2 ghc-8.2.2 ghc-8.4.4 ghc-8.6.2 ghc-8.6.3 ghc-8.6.4 \
            ghc-8.6.5 ghc-8.8.1 ghc-8.8.2 ghc-8.8.3 ghc-8.10.1 cabal-install-2.0 cabal-install-2.2 \
            cabal-install-2.4 cabal-install-3.0 cabal-install-3.2 heroku imagemagick \
            libmagickcore-dev libmagickwand-dev libmagic-dev ant ant-optional kubectl \
            mercurial apt-transport-https mono-complete mysql-client libmysqlclient-dev \
            mysql-server mssql-tools unixodbc-dev yarn bazel chrpath libssl-dev libxft-dev \
            libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev php7.1 php7.1-bcmath \
            php7.1-bz2 php7.1-cgi php7.1-cli php7.1-common php7.1-curl php7.1-dba php7.1-dev \
            php7.1-enchant php7.1-fpm php7.1-gd php7.1-gmp php7.1-imap php7.1-interbase php7.1-intl \
            php7.1-json php7.1-ldap php7.1-mbstring php7.1-mcrypt php7.1-mysql php7.1-odbc \
            php7.1-opcache php7.1-pgsql php7.1-phpdbg php7.1-pspell php7.1-readline php7.1-recode \
            php7.1-snmp php7.1-soap php7.1-sqlite3 php7.1-sybase php7.1-tidy php7.1-xml \
            php7.1-xmlrpc php7.1-xsl php7.1-zip php7.2 php7.2-bcmath php7.2-bz2 php7.2-cgi \
            php7.2-cli php7.2-common php7.2-curl php7.2-dba php7.2-dev php7.2-enchant php7.2-fpm \
            php7.2-gd php7.2-gmp php7.2-imap php7.2-interbase php7.2-intl php7.2-json php7.2-ldap \
            php7.2-mbstring php7.2-mysql php7.2-odbc php7.2-opcache php7.2-pgsql php7.2-phpdbg \
            php7.2-pspell php7.2-readline php7.2-recode php7.2-snmp php7.2-soap php7.2-sqlite3 \
            php7.2-sybase php7.2-tidy php7.2-xml php7.2-xmlrpc php7.2-xsl php7.2-zip php7.3 \
            php7.3-bcmath php7.3-bz2 php7.3-cgi php7.3-cli php7.3-common php7.3-curl php7.3-dba \
            php7.3-dev php7.3-enchant php7.3-fpm php7.3-gd php7.3-gmp php7.3-imap php7.3-interbase \
            php7.3-intl php7.3-json php7.3-ldap php7.3-mbstring php7.3-mysql php7.3-odbc \
            php7.3-opcache php7.3-pgsql php7.3-phpdbg php7.3-pspell php7.3-readline php7.3-recode \
            php7.3-snmp php7.3-soap php7.3-sqlite3 php7.3-sybase php7.3-tidy php7.3-xml \
            php7.3-xmlrpc php7.3-xsl php7.3-zip php7.4 php7.4-bcmath php7.4-bz2 php7.4-cgi \
            php7.4-cli php7.4-common php7.4-curl php7.4-dba php7.4-dev php7.4-enchant php7.4-fpm \
            php7.4-gd php7.4-gmp php7.4-imap php7.4-interbase php7.4-intl php7.4-json php7.4-ldap \
            php7.4-mbstring php7.4-mysql php7.4-odbc php7.4-opcache php7.4-pgsql php7.4-phpdbg \
            php7.4-pspell php7.4-readline php7.4-snmp php7.4-soap php7.4-sqlite3 php7.4-sybase \
            php7.4-tidy php7.4-xml php7.4-xmlrpc php7.4-xsl php7.4-zip php-amqp php-apcu \
            php-igbinary php-memcache php-memcached php-mongodb php-redis php-xdebug \
            php-zmq snmp pollinate libpq-dev postgresql-client powershell ruby-full \
            sphinxsearch subversion mongodb-org -yq >/dev/null 2>&1 || true
          sudo apt-get autoremove -y >/dev/null 2>&1 || true
          sudo apt-get autoclean -y >/dev/null 2>&1 || true
      - 
        name: Check disk space
        run: df -h
      -
        name: Checkout
        uses: actions/checkout@v3
      - 
        name: Check working space directory
        run: du ${GITHUB_WORKSPACE} -h -d 1
      - 
        name: Get more space
        run: |
          df -h
          sudo rm -rf ${GITHUB_WORKSPACE}/.git
          df -h
neilmayhew commented 2 months ago
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"

For the benefit of those who come across this several years later, as I did, here's a more up-to-date list of big things that you could remove at the start of a build:

# Remove software and language runtimes we're not using
sudo rm -rf \
  "$AGENT_TOOLSDIRECTORY" \
  /opt/google/chrome \
  /opt/microsoft/msedge \
  /opt/microsoft/powershell \
  /opt/pipx \
  /usr/lib/mono \
  /usr/local/julia* \
  /usr/local/lib/android \
  /usr/local/lib/node_modules \
  /usr/local/share/chromium \
  /usr/local/share/powershell \
  /usr/share/dotnet \
  /usr/share/swift
df -h /
BrentMifsud commented 1 month ago

so it seems the suggestion above was not clearing up enough space for me.

What I ended up doing was just deleting all the unused versions of Xcode from my Mac runner as one of the initial steps:

   - name: Delete Unused Xcode Versions
      shell: bash
      run: |
        # when changing xcode version below, be sure to update this script!!!
        echo "Deleting unused Xcode Versions..."
        cd /Applications/
        mv Xcode_15.4.app Ycode_15.4.app
        sudo rm -rf Xcode*
        mv Ycode_15.4.app Xcode_15.4.app

I'm no bash expert, so I'm sure theres a more elegant way of doing this. Still have no idea why this randomly started on Friday for us though. Our builds were working fine.

BrentMifsud commented 1 month ago
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"

For the benefit of those who come across this several years later, as I did, here's a more up-to-date list of big things that you could remove at the start of a build:

# Remove software and language runtimes we're not using
sudo rm -rf \
  "$AGENT_TOOLSDIRECTORY" \
  /opt/google/chrome \
  /opt/microsoft/msedge \
  /opt/microsoft/powershell \
  /opt/pipx \
  /usr/lib/mono \
  /usr/local/julia* \
  /usr/local/lib/android \
  /usr/local/lib/node_modules \
  /usr/local/share/chromium \
  /usr/local/share/powershell \
  /usr/share/dotnet \
  /usr/share/swift
df -h /

If you are using a Mac runner, one thing you might want to add to this list is all the versions of Xcode you are not using.

We only needed Xcode 15.4, but these runners have half a dozen versions of Xcode installed. Thats a few GB of storage space for each.

Hoverbear commented 1 month ago

@BrentMifsud thanks for the breadcrumb here.

You can remove all but the latest Xcode with:

find /Applications/ -name "Xcode*" | sort -r | tail --lines=+2 | xargs rm -rf
BrentMifsud commented 1 month ago

@BrentMifsud thanks for the breadcrumb here.

You can remove all but the latest Xcode with:


find /Applications/ -name "Xcode*" | sort -r | tail --lines=+2 | xargs rm -rf

Thanks for this. Definitely much better than my solution

Aaron-Ritter commented 1 month ago
find /Applications/ -name "Xcode*" | sort -r | tail --lines=+2 | xargs rm -rf

great hint, thanks!

i did implement it slightly different as you just have to remove the different folders and not each file individually:

In addition i coupled it with a matrix.xcode variable to initialization xcode in a specific version so basically what i initialize i want to keep and if i like i can run it against different versions of xcode.

      - name: Initialize latest xcode
        uses: maxim-lobanov/setup-xcode@v1.6.0
        with:
          xcode-version: ${{ matrix.xcode }}

      - name: Remove old xcode versions
        run: |
          echo "Searching for Xcode versions:"
          find /Applications -name "Xcode_*" -maxdepth 1 -mindepth 1
          echo "Removing old Xcode versions..."
          find /Applications -name "Xcode_*" -maxdepth 1 -mindepth 1 | grep -v ${{ matrix.xcode }} | xargs rm -rf
          echo "Available Xcode versions after removal:"
          find /Applications -name "Xcode_*" -maxdepth 1 -mindepth 1