-
Notifications
You must be signed in to change notification settings - Fork 13.9k
CI: use alternative disks if available #148146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
the8472
wants to merge
2
commits into
rust-lang:master
Choose a base branch
from
the8472:ci-use-extra-disk
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+60
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -247,12 +247,71 @@ cleanSwap() { | |
| free -h | ||
| } | ||
|
|
||
| # Try to find a different drive to put our data on so we don't need to run cleanup. | ||
| # The availability of the disks we're probing isn't guaranteed, | ||
| # so this is opportunistic. | ||
| checkAlternative() { | ||
| local gha_alt_disk="/mnt" | ||
|
|
||
| # we need ~50GB of space | ||
| local space_target_kb=$((50 * 1024 * 1024)) | ||
| local available_space_kb=$(df -k "$gha_alt_disk" --output=avail | tail -n 1) | ||
|
|
||
| # mount options that trade durability for performance | ||
| # ignore-tidy-linelength | ||
| local mntopts="defaults,discard,journal_async_commit,barrier=0,noauto_da_alloc,lazytime,data=writeback" | ||
|
|
||
| # GHA has a 2nd disk mounted at /mnt that is almost empty. | ||
| # Check if it's a valid mountpoint and it has enough available space. | ||
| if mountpoint "$gha_alt_disk" && [ "$available_space_kb" -ge "$space_target_kb" ]; then | ||
| local blkdev=$(df -k "$gha_alt_disk" --output=source | tail -n 1) | ||
| echo "Sufficient space available on $blkdev mounted at $gha_alt_disk" | ||
| # see cleanSwap(), swapfile may be mounted under /mnt | ||
| sudo swapoff -a || true | ||
|
|
||
| # unmount from original location | ||
| sudo umount "$gha_alt_disk" | ||
|
|
||
| # remount under the obj dir which is used by docker scripts to write most | ||
| # of our build output. And apply optimized mount options while we're at it. | ||
| mkdir ./obj | ||
| sudo mount $blkdev ./obj -o $mntopts || (sudo dmesg | tail -n 20 ; exit 1) | ||
|
|
||
| # ensure current user can access everything. | ||
| # later scripts assume they have recursive access to obj | ||
| sudo chown -R "$USER":"$USER" ./obj | ||
|
|
||
| # Exit from this script to avoid wasting time removing disk space, | ||
| # as we already have enough disk space in the alternative drive. | ||
| exit 0 | ||
the8472 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| fi | ||
|
|
||
| # ephemeral NVMe drives on AWS | ||
| for dev in /dev/nvme*n1; do | ||
| # check that it's a blockdev and not mounted. | ||
| if [ -b "$dev" ] && [ "$(mount | grep "$dev" | wc -l)" -eq 0 ]; then | ||
| echo "Found unused block device $dev, creating filesystem" | ||
| sudo mkfs.ext4 -E lazy_itable_init=1,lazy_journal_init=1 "$dev" | ||
| mkdir ./obj | ||
| sudo mount "$dev" ./obj -o $mntopts | ||
| sudo chown -R "$USER":"$USER" ./obj | ||
|
|
||
| exit 0 | ||
| fi | ||
| done | ||
| } | ||
|
|
||
|
|
||
|
|
||
| # Display initial disk space stats | ||
|
|
||
| AVAILABLE_INITIAL=$(getAvailableSpace) | ||
|
|
||
| printDF "BEFORE CLEAN-UP:" | ||
| echo "" | ||
|
|
||
| checkAlternative | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and moved this down a bit so we always print the disk space before, useful for later reference in case it was not sufficient. |
||
|
|
||
| execAndMeasureSpaceChange cleanPackages "Unused packages" | ||
| execAndMeasureSpaceChange cleanDocker "Docker images" | ||
| execAndMeasureSpaceChange cleanSwap "Swap storage" | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added an exit 1 here