Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
vagrantfile: Fix vagrant up fedora
Browse files Browse the repository at this point in the history
Since the commit 26cef9d Podman has been used to build the osbuilder
image if on Fedora.

Fedora 32 onward defaults to cgroups v2 which break some tools. The
Vagrantfile instructs the VM to switch back to cgroups v1 (that needs reboot). However
currently it executes the setup script before the reboot (i.e. still cgroups v2)
and then Podman has failed to build the osbuilder image.

With this change the setup script is executed after the reboot, Podman happily uses
cgroup v1, thus the osbuilder image is built.

Fixes #3760
Signed-off-by: Wainer dos Santos Moschetta <[email protected]>
  • Loading branch information
wainersm committed Sep 1, 2021
1 parent 5878abf commit 8693c3e
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
job = ENV['CI_JOB'] || ""
guest_user = 'vagrant'
guest_home_dir = '/home/vagrant'
# The file on the guest where environment variables are going to be set
# to export.
guest_env_file = guest_home_dir + '/ci_job_env'

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
Expand Down Expand Up @@ -48,7 +51,7 @@ Vagrant.configure("2") do |config|
chown -R #{guest_user}:#{guest_user} "${GOPATH}"
kata_tests_repo_dir="${GOPATH}/src/github.com/kata-containers/tests"
env_file="#{guest_home_dir}/ci_job_env"
env_file="#{guest_env_file}"
sudo -E PATH=$PATH -H -u #{guest_user} \
cat <<-EOF > ${env_file}
export GOPATH="$GOPATH"
Expand All @@ -71,12 +74,6 @@ EOF
distro=$(source /etc/os-release; echo $ID)
case "$distro" in
"fedora")
# Fedora >= 32 Kernel comes configured with cgroup v2 by default.
# This switches back to cgroup v1. It requires a reboot.
sudo dnf install -y grubby
sudo grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=0"
;;
"ubuntu")
# TODO: redis-server package fails to install if IPv6 is disabled. Move this
# code to the setup script.
Expand All @@ -86,24 +83,35 @@ EOF
fi
;;
esac
# Build the osbuilder with same distro as the host.
export osbuilder_distro="$distro"
cd ${kata_tests_repo_dir}
sudo -E PATH=$PATH -H -u #{guest_user} bash -c '.ci/setup.sh'
SHELL

config.vm.define "fedora", autostart: false do |fedora|
fedora.vm.box = "fedora/32-cloud-base"
# Fedora is required to reboot so that the change to cgroups v1
# makes effect.
fedora.vm.provision "shell", reboot: true, inline: <<-SHELL
echo "Need to reboot the VM"
sudo dnf install -y grubby
# Set the kernel parameter to use cgroups v1.
sudo grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=0"
SHELL

fedora.vm.provision "shell", inline: <<-SHELL
source "#{guest_env_file}"
cd "${GOPATH}/src/github.com/kata-containers/tests"
# Build the osbuilder with same distro as the host.
export osbuilder_distro="fedora"
sudo -E PATH=$PATH -H -u #{guest_user} bash -c '.ci/setup.sh'
SHELL
end

config.vm.define "ubuntu", autostart: false do |ubuntu|
ubuntu.vm.box = "generic/ubuntu2004"
ubuntu.vm.provision "shell", inline: <<-SHELL
source "#{guest_env_file}"
cd "${GOPATH}/src/github.com/kata-containers/tests"
# Build the osbuilder with same distro as the host.
export osbuilder_distro="ubuntu"
sudo -E PATH=$PATH -H -u #{guest_user} bash -c '.ci/setup.sh'
SHELL
end
end

0 comments on commit 8693c3e

Please sign in to comment.