cicd system_error ai_generated true

错误:自托管运行器遇到磁盘空间问题:设备上没有剩余空间

Error: The self-hosted runner encountered a disk space issue: No space left on device

ID: cicd/github-actions-self-hosted-runner-disk-full

其他格式: JSON · Markdown 中文 · English
88%修复率
85%置信度
1证据数
2024-01-15首次发现

版本兼容性

版本状态引入弃用备注
GitHub Actions Runner v2.311.0 active
Ubuntu 22.04 LTS active

根因分析

自托管 GitHub Actions 运行器因累积的构建产物、缓存的 Docker 镜像或日志文件而耗尽磁盘空间

English

Self-hosted GitHub Actions runner has exhausted disk space due to accumulated build artifacts, cached Docker images, or log files

generic

官方文档

https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners

解决方案

  1. Add a cleanup cron job on the runner: '0 0 * * * docker system prune -af --volumes && rm -rf /home/runner/_work/* && df -h' to remove unused Docker images and old workspace data nightly
  2. Configure a pre-job step in workflows to check disk space and fail early with a message: 'df -h / | tail -1 | awk "{print \$5}" | sed "s/%//" | xargs -I {} sh -c "if [ {} -gt 85 ]; then echo \"Disk usage {}% exceeds 85%\"; exit 1; fi"'
  3. Use ephemeral runners with auto-scaling that are destroyed after each job to prevent disk accumulation

无效尝试

常见但无效的做法:

  1. 70% 失败

    Increasing runner disk size via cloud provider without cleaning existing files only delays the issue and increases cost

  2. 60% 失败

    Manually deleting random files in /tmp may break running workflows or cause permission errors

  3. 75% 失败

    Adding more runners without addressing disk cleanup multiplies the problem across the fleet