chore: add disk space cleanup steps to CI pipeline (Phase 3)#8279
chore: add disk space cleanup steps to CI pipeline (Phase 3)#8279vhvb1989 wants to merge 4 commits into
Conversation
Add a reusable cleanup-disk-space.yml step template and insert it at strategic points in the Linux CI jobs to address 71 'Free disk space on / is lower than 5%' warnings. Cleanup points in build-cli.yml: - After test run: clean Go cache, NuGet, and .NET temp artifacts - After release build: clean Go build cache - After Linux package build: clean Docker images/containers Cleanup points in cross-build-cli.yml: - After Linux ARM64 package build: clean Docker and Go cache All cleanup steps are Linux-only, use continueOnError to avoid breaking builds, and log disk usage before/after for observability. Resolves #7783 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a reusable Azure Pipelines step template to reclaim disk space on Linux build agents and wires it into the CLI build job templates to reduce “Free disk space on / is lower than 5%” warnings.
Changes:
- Added a reusable
cleanup-disk-space.ymlstep template with parameterized cleanup targets (Docker, Go cache, NuGet, .NET temp) and before/after disk usage logging. - Inserted cleanup steps into
build-cli.ymlat multiple points in the job to reduce transient disk pressure. - Inserted cleanup steps into
cross-build-cli.ymlafter Linux ARM64 package build.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| eng/pipelines/templates/steps/cleanup-disk-space.yml | New reusable cleanup template (Linux-only) for reclaiming disk space via targeted cache/prune steps. |
| eng/pipelines/templates/jobs/build-cli.yml | Adds multiple invocations of the cleanup template during the BuildCLI job. |
| eng/pipelines/templates/jobs/cross-build-cli.yml | Adds a cleanup invocation after the Linux ARM64 package build. |
- Remove CleanGoCache from post-test cleanup to preserve cache for release build - Add BuildLinuxPackages condition to Docker cleanup in build-cli.yml - Add BuildLinuxPackages condition to Docker+Go cleanup in cross-build-cli.yml Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove redundant 2>/dev/null || true from cleanup commands; rely on continueOnError - Update PR description to reflect post-test cleanup no longer includes Go cache Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run azure-dev - cli |
|
Azure Pipelines could not run because the pipeline triggers exclude this branch/path. |
📋 Prioritization NoteThanks for the contribution! The linked issue isn't in the current milestone yet. |
There was a problem hiding this comment.
This cleanup template is a good targeted way to reduce Linux agent disk pressure, and the latest iteration addresses the earlier cache-timing and condition feedback. The Linux gating, continueOnError, and before/after df -h / logging make the cleanup behavior observable without making cleanup failures block the build.
I found two follow-up items worth addressing or confirming before merge:
-
eng/pipelines/templates/jobs/build-cli.ymllines 174-178
The post-test cleanup uses the template default condition ofsucceeded(). If the test step fails,Publish test resultsstill runs because it usessucceededOrFailed(), but this cleanup step will be skipped. Since reclaiming disk is still useful after failed tests, passCondition: succeededOrFailed()for this invocation. -
The affected Azure Pipelines template path does not appear to have been exercised on this PR. The
/azp run azure-dev - cliattempt was excluded by pipeline triggers, so the new compile-time${{ if }}blocks and composed runtime conditions have not been validated in the target ADO pipeline. Please run the affected pipeline to confirm template expansion for the new cleanup wiring.
- Add Go cache cleanup BEFORE Linux package build (not just after) - Split cleanup: Go cache before Docker build, Docker after - Add temp/cache directory overrides (DOCKER_TMPDIR, TMPDIR, GOCACHE) to CrossBuildCLI LinuxARM64 matrix entry, matching BuildCLI Linux Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Add disk space cleanup steps to the CI pipeline to eliminate 71 "Free disk space on / is lower than 5%" warnings on Linux agents (~62% of all pipeline warnings).
Changes
New file
eng/pipelines/templates/steps/cleanup-disk-space.yml— Reusable cleanup step template with parameterized targets (Docker, Go cache, NuGet, .NET temp). All steps are Linux-only, usecontinueOnError: true, and logdf -h /before/after for observability.Modified files
eng/pipelines/templates/jobs/build-cli.yml— 3 cleanup insertions:BuildLinuxPackages)eng/pipelines/templates/jobs/cross-build-cli.yml— 1 cleanup insertion:BuildLinuxPackages)Design Decisions
continueOnError: true— cleanup failures never break the buildeq(variables['Agent.OS'], 'Linux')since warnings only affect Linux agents${{ if }}blocks ensure only requested cleanup operations are emitted in each invocationRelated Issues
Closes #7783
Parent: #4668
Full analysis: Azure/azure-dev-pr#1780