Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ci/docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ docker \
--env DEPLOY \
--env DEPLOY_ALT \
--env CI \
--env GIT_DISCOVERY_ACROSS_FILESYSTEM=1 \
--env GITHUB_ACTIONS \
--env GITHUB_REF \
--env GITHUB_STEP_SUMMARY="/checkout/obj/${SUMMARY_FILE}" \
Expand Down
44 changes: 44 additions & 0 deletions src/ci/scripts/free-disk-space-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Member

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 mountpoint command


# 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# GHA has a 2nd disk mounted at /mnt that is almost empty
# 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 /mnt && [ "$available_space_kb" -ge "$space_target_kb" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we reuse the variable instead of hardcoding /mnt?

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
Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
exit 0
# Exit from this script to avoid wasting time removing disk space,
# as we already have enough disk space in the alternative drive.
exit 0

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)
Expand Down
Loading