Skip to content

Commit 5c6810b

Browse files
Auto merge of #148146 - the8472:ci-use-extra-disk, r=<try>
CI: use alternative disks if available try-job: dist-x86_64-linux try-job: x86_64-gnu-aux try-job: dist-aarch64-linux try-job: aarch64-gnu-llvm-20-1
2 parents dfe1b8c + 32902a9 commit 5c6810b

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

src/ci/docker/run.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ docker \
347347
--env DEPLOY \
348348
--env DEPLOY_ALT \
349349
--env CI \
350+
--env GIT_DISCOVERY_ACROSS_FILESYSTEM=1 \
350351
--env GITHUB_ACTIONS \
351352
--env GITHUB_REF \
352353
--env GITHUB_STEP_SUMMARY="/checkout/obj/${SUMMARY_FILE}" \

src/ci/scripts/free-disk-space-linux.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,75 @@ cleanSwap() {
247247
free -h
248248
}
249249

250+
# Try to find a different drive to put our data on so we don't need to run cleanup.
251+
# The availability of the disks we're probing isn't guaranteed,
252+
# so this is opportunistic.
253+
checkAlternative() {
254+
local gha_alt_disk="/mnt"
255+
256+
# we need ~50GB of space
257+
local space_target_kb=$((50 * 1024 * 1024))
258+
local available_space_kb=$(df -k "$gha_alt_disk" --output=avail | tail -n 1)
259+
260+
# mount options that trade durability for performance
261+
# ignore-tidy-linelength
262+
local mntopts="defaults,discard,journal_async_commit,barrier=0,noauto_da_alloc,lazytime,data=writeback"
263+
264+
# GHA has a 2nd disk mounted at /mnt that is almost empty.
265+
# Check if it's a valid mountpoint and it has enough available space.
266+
if mountpoint "$gha_alt_disk" && [ "$available_space_kb" -ge "$space_target_kb" ]; then
267+
local blkdev=$(df -k "$gha_alt_disk" --output=source | tail -n 1)
268+
echo "Sufficient space available on $blkdev mounted at $gha_alt_disk"
269+
# see cleanSwap(), swapfile may be mounted under /mnt
270+
sudo swapoff -a || true
271+
272+
# unmount from original location
273+
sudo umount "$gha_alt_disk"
274+
275+
# remount under the obj dir which is used by docker scripts to write most
276+
# of our build output. And apply optimized mount options while we're at it.
277+
mkdir ./obj
278+
if ! sudo mount $blkdev ./obj -o $mntopts; then
279+
sudo dmesg | tail -n 20 # kernel log should have more details for mount failures
280+
echo "::warning::Failed to remount $blkdev to ./obj with options: $mntopts"
281+
return
282+
fi
283+
284+
# ensure current user can access everything.
285+
# later scripts assume they have recursive access to obj
286+
sudo chown -R "$USER":"$USER" ./obj
287+
288+
# Exit from this script to avoid wasting time removing disk space,
289+
# as we already have enough disk space in the alternative drive.
290+
exit 0
291+
fi
292+
293+
# ephemeral NVMe drives on AWS
294+
for dev in /dev/nvme*n1; do
295+
# check that it's a blockdev and not mounted.
296+
if [ -b "$dev" ] && [ "$(mount | grep "$dev" | wc -l)" -eq 0 ]; then
297+
echo "Found unused block device $dev, creating filesystem"
298+
sudo mkfs.ext4 -E lazy_itable_init=1,lazy_journal_init=1 "$dev"
299+
mkdir ./obj
300+
sudo mount "$dev" ./obj -o $mntopts
301+
sudo chown -R "$USER":"$USER" ./obj
302+
303+
exit 0
304+
fi
305+
done
306+
}
307+
308+
309+
250310
# Display initial disk space stats
251311

252312
AVAILABLE_INITIAL=$(getAvailableSpace)
253313

254314
printDF "BEFORE CLEAN-UP:"
255315
echo ""
316+
317+
checkAlternative
318+
256319
execAndMeasureSpaceChange cleanPackages "Unused packages"
257320
execAndMeasureSpaceChange cleanDocker "Docker images"
258321
execAndMeasureSpaceChange cleanSwap "Swap storage"

0 commit comments

Comments
 (0)