-
Notifications
You must be signed in to change notification settings - Fork 68
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
ci: increase available disk space for GHA container image builds #577
Merged
openshift-merge-bot
merged 2 commits into
opendatahub-io:main
from
jiridanek:jd_wip_image_building_lvm_overlay_etc
Jun 26, 2024
Merged
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 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 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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/usr/bin/env bash | ||
set -Eeuo pipefail | ||
|
||
# GitHub Actions runners have two disks, /dev/root and /dev/sda1. | ||
# We would like to be able to combine available disk space on both and use it for podman container builds. | ||
# | ||
# This script creates file-backed volumes on /dev/root and /dev/sda1, then creates ext4 over both, and mounts it for our use | ||
# https://github.com/easimon/maximize-build-space/blob/master/action.yml | ||
|
||
root_reserve_mb=2048 | ||
temp_reserve_mb=100 | ||
swap_size_mb=4096 | ||
|
||
build_mount_path="${HOME}/.local/share/containers" | ||
build_mount_path_ownership="runner:runner" | ||
|
||
pv_loop_path=/pv.img | ||
tmp_pv_loop_path=/mnt/tmp-pv.img | ||
overprovision_lvm=false | ||
|
||
VG_NAME=buildvg | ||
|
||
# github runners have an active swap file in /mnt/swapfile | ||
# we want to reuse the temp disk, so first unmount swap and clean the temp disk | ||
echo "Unmounting and removing swap file." | ||
sudo swapoff -a | ||
sudo rm -f /mnt/swapfile | ||
|
||
echo "Creating LVM Volume." | ||
echo " Creating LVM PV on root fs." | ||
# create loop pv image on root fs | ||
ROOT_RESERVE_KB=$(expr ${root_reserve_mb} \* 1024) | ||
ROOT_FREE_KB=$(df --block-size=1024 --output=avail / | tail -1) | ||
ROOT_LVM_SIZE_KB=$(expr $ROOT_FREE_KB - $ROOT_RESERVE_KB) | ||
ROOT_LVM_SIZE_BYTES=$(expr $ROOT_LVM_SIZE_KB \* 1024) | ||
sudo touch "${pv_loop_path}" && sudo fallocate -z -l "${ROOT_LVM_SIZE_BYTES}" "${pv_loop_path}" | ||
export ROOT_LOOP_DEV=$(sudo losetup --find --show "${pv_loop_path}") | ||
sudo pvcreate -f "${ROOT_LOOP_DEV}" | ||
|
||
# create pv on temp disk | ||
echo " Creating LVM PV on temp fs." | ||
TMP_RESERVE_KB=$(expr ${temp_reserve_mb} \* 1024) | ||
TMP_FREE_KB=$(df --block-size=1024 --output=avail /mnt | tail -1) | ||
TMP_LVM_SIZE_KB=$(expr $TMP_FREE_KB - $TMP_RESERVE_KB) | ||
TMP_LVM_SIZE_BYTES=$(expr $TMP_LVM_SIZE_KB \* 1024) | ||
sudo touch "${tmp_pv_loop_path}" && sudo fallocate -z -l "${TMP_LVM_SIZE_BYTES}" "${tmp_pv_loop_path}" | ||
export TMP_LOOP_DEV=$(sudo losetup --find --show "${tmp_pv_loop_path}") | ||
sudo pvcreate -f "${TMP_LOOP_DEV}" | ||
|
||
# create volume group from these pvs | ||
sudo vgcreate "${VG_NAME}" "${TMP_LOOP_DEV}" "${ROOT_LOOP_DEV}" | ||
|
||
echo "Recreating swap" | ||
# create and activate swap | ||
sudo lvcreate -L "${swap_size_mb}M" -n swap "${VG_NAME}" | ||
sudo mkswap "/dev/mapper/${VG_NAME}-swap" | ||
sudo swapon "/dev/mapper/${VG_NAME}-swap" | ||
|
||
echo "Creating build volume" | ||
# create and mount build volume | ||
sudo lvcreate --type raid0 --stripes 2 --stripesize 4 --alloc anywhere --extents 100%FREE --name buildlv "${VG_NAME}" | ||
if [[ ${overprovision_lvm} == 'true' ]]; then | ||
sudo mkfs.ext4 -m0 "/dev/mapper/${VG_NAME}-buildlv" | ||
else | ||
sudo mkfs.ext4 -Enodiscard -m0 "/dev/mapper/${VG_NAME}-buildlv" | ||
fi | ||
sudo mount "/dev/mapper/${VG_NAME}-buildlv" "${build_mount_path}" | ||
sudo chown -R "${build_mount_path_ownership}" "${build_mount_path}" | ||
|
||
# if build mount path is a parent of $GITHUB_WORKSPACE, and has been deleted, recreate it | ||
if [[ ! -d "${GITHUB_WORKSPACE}" ]]; then | ||
sudo mkdir -p "${GITHUB_WORKSPACE}" | ||
sudo chown -R "${WORKSPACE_OWNER}" "${GITHUB_WORKSPACE}" | ||
fi |
This file contains 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
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.
use_hard_links = "false"
is what's shown in the blog