-
Couldn't load subscription status.
- 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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -247,6 +247,50 @@ 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 mountpoint="/mnt" | ||||||||||
|
|
||||||||||
| # we need ~50GB of space | ||||||||||
| local space_target_kb=$((50 * 1024 * 1024)) | ||||||||||
| local available_space_kb=$(df -k "$mountpoint" --output=avail | tail -n 1) | ||||||||||
|
|
||||||||||
| # 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 | ||||||||||
|
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.
Suggested change
|
||||||||||
| if mountpoint /mnt && [ "$available_space_kb" -ge "$space_target_kb" ]; then | ||||||||||
|
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. should we reuse the variable instead of hardcoding |
||||||||||
| local blkdev=$(df -k "$mountpoint" --output=source | tail -n 1) | ||||||||||
| echo "Sufficient space available on $blkdev mounted at $mountpoint" | ||||||||||
| sudo swapoff -a || true | ||||||||||
| mkdir ./obj | ||||||||||
| # remount with O_EATMYDATA while we're at it | ||||||||||
| sudo umount /mnt | ||||||||||
| sudo mount $blkdev ./obj -o $mntopts || sudo dmesg | tail -n 20 | ||||||||||
| sudo chown -R "$USER":"$USER" ./obj | ||||||||||
|
Comment on lines
+265
to
+272
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. can you add more comments explaining what you are doing here? 🙏 |
||||||||||
|
|
||||||||||
| exit 0 | ||||||||||
|
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.
Suggested change
|
||||||||||
| fi | ||||||||||
|
|
||||||||||
| # ephemeral NVMe drives on AWS | ||||||||||
| for dev in /dev/nvme*n1; do | ||||||||||
| 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 | ||||||||||
| } | ||||||||||
|
|
||||||||||
|
|
||||||||||
| checkAlternative | ||||||||||
|
|
||||||||||
| # Display initial disk space stats | ||||||||||
|
|
||||||||||
| AVAILABLE_INITIAL=$(getAvailableSpace) | ||||||||||
|
|
||||||||||
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.
I find confusing naming the variable as the
mountpointcommand