Skip to content
Merged
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
91 changes: 91 additions & 0 deletions .github/actions/bootc-ubuntu-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: 'Bootc Ubuntu Setup'
description: 'Default host setup'
inputs:
libvirt:
description: 'Install libvirt and virtualization stack'
required: false
default: 'false'
runs:
using: 'composite'
steps:
# The default runners have TONS of crud on them...
- name: Free up disk space on runner
shell: bash
run: |
set -xeuo pipefail
sudo df -h
unwanted_pkgs=('^aspnetcore-.*' '^dotnet-.*' '^llvm-.*' 'php.*' '^mongodb-.*' '^mysql-.*'
azure-cli google-chrome-stable firefox mono-devel)
unwanted_dirs=(/usr/share/dotnet /opt/ghc /usr/local/lib/android /opt/hostedtoolcache/CodeQL)
# Start background removal operations as systemd units; if this causes
# races in the future around disk space we can look at waiting for cleanup
# before starting further jobs, but right now we spent a lot of time waiting
# on the network and scripts and such below, giving these plenty of time to run.
n=0
runcleanup() {
sudo systemd-run -r -u action-cleanup-${n} -- "$@"
n=$(($n + 1))
}
runcleanup docker image prune --all --force
for x in ${unwanted_dirs[@]}; do
runcleanup rm -rf "$x"
done
# Apt removals in foreground, as we can't parallelize these
for x in ${unwanted_pkgs[@]}; do
/bin/time -f '%E %C' sudo apt-get remove -y $x

Choose a reason for hiding this comment

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

medium

It's a good shell scripting practice to quote variables when expanding them, especially in commands, to prevent word splitting or glob expansion. While apt-get remove package names typically don't contain spaces, using "$x" ensures robustness against unexpected characters.

/bin/time -f '%E %C' sudo apt-get remove -y "$x"

done
# We really want support for heredocs
- name: Update podman and install just
shell: bash
run: |
set -eux
# Require the runner is ubuntu-24.04
IDV=$(. /usr/lib/os-release && echo ${ID}-${VERSION_ID})
test "${IDV}" = "ubuntu-24.04"
# plucky is the next release
echo 'deb http://azure.archive.ubuntu.com/ubuntu plucky universe main' | sudo tee /etc/apt/sources.list.d/plucky.list
/bin/time -f '%E %C' sudo apt update
# skopeo is currently older in plucky for some reason hence --allow-downgrades
/bin/time -f '%E %C' sudo apt install -y --allow-downgrades crun/plucky podman/plucky skopeo/plucky just
# This is the default on e.g. Fedora derivatives, but not Debian
- name: Enable unprivileged /dev/kvm access
shell: bash
run: |
set -xeuo pipefail

Choose a reason for hiding this comment

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

high

Setting MODE="0666" for /dev/kvm makes it world-writable, which is a significant security concern. It's best practice to restrict access to the kvm group by using MODE="0660" and ensuring the user running the CI is part of that group. This minimizes the attack surface.

echo 'KERNEL=="kvm", GROUP="kvm", MODE="0660", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules

Copy link
Member Author

Choose a reason for hiding this comment

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

Same thing is done on bootc-dev/infra and is just for the ephemeral runners. @cgwalters Is this valid to you?

Copy link
Member

Choose a reason for hiding this comment

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

Nah I think /dev/kvm is fine to be world accessible, it's a pretty hardened kernel interface overall.

echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
ls -l /dev/kvm
# Used by a few workflows, but generally useful
- name: Set architecture variable
id: set_arch
shell: bash
run: echo "ARCH=$(arch)" >> $GITHUB_ENV
# Install libvirt stack if requested
- name: Install libvirt and virtualization stack
if: ${{ inputs.libvirt == 'true' }}
shell: bash
run: |
set -xeuo pipefail
export BCVK_VERSION=0.8.0
/bin/time -f '%E %C' sudo apt install -y libkrb5-dev pkg-config libvirt-dev genisoimage qemu-utils qemu-kvm virtiofsd libvirt-daemon-system
# Something in the stack is overriding this, but we want session right now for bcvk
echo LIBVIRT_DEFAULT_URI=qemu:///session >> $GITHUB_ENV
td=$(mktemp -d)
cd $td
# Install bcvk
target=bcvk-$(arch)-unknown-linux-gnu
/bin/time -f '%E %C' curl -LO https://github.com/bootc-dev/bcvk/releases/download/v${BCVK_VERSION}/${target}.tar.gz
tar xzf ${target}.tar.gz
sudo install -T ${target} /usr/bin/bcvk
cd -
rm -rf "$td"

# Also bump the default fd limit as a workaround for https://github.com/bootc-dev/bcvk/issues/65
sudo sed -i -e 's,^\* hard nofile 65536,* hard nofile 524288,' /etc/security/limits.conf

Choose a reason for hiding this comment

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

medium

The current sed command relies on the exact line * hard nofile 65536 being present in /etc/security/limits.conf. If this line is missing or differs, the file descriptor limit will not be updated, potentially leaving the workaround for bootc-dev/bcvk#65 unapplied. A more robust and less intrusive approach is to create a new file in /etc/security/limits.d/ to set the limit, which will be respected by systemd and login.

echo "* hard nofile 524288" | sudo tee /etc/security/limits.d/99-bcvk.conf

- name: Cleanup status
shell: bash
run: |
set -xeuo pipefail
systemctl list-units 'action-cleanup*'
df -h
9 changes: 1 addition & 8 deletions .github/workflows/bootc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,7 @@ jobs:
stream: [stream9, stream10]
steps:
- uses: actions/checkout@v4
- name: Installdeps
run: sudo apt update && sudo apt install just
- name: Get a newer podman for heredoc support (from debian testing)
run: |
set -eux
echo 'deb [trusted=yes] https://ftp.debian.org/debian/ testing main' | sudo tee /etc/apt/sources.list.d/testing.list
sudo apt update
sudo apt install -y crun/testing podman/testing skopeo/testing
- uses: ./.github/actions/bootc-ubuntu-setup
- name: build
run: sudo STREAM=${{ matrix.stream }} just build
- name: unitcontainer
Expand Down
Loading