util: Make all runners the same type

Having two types of GitHub Action Runners has not yielded much benefit
and caused confusion and inefficiencies. This change simplifies things
to having just one runner with 8-cores and 16GB of memory. It is
sufficient to build gem5 and run most simulations.

Change-Id: Ic49ae5e98b02086f153f4ae2a4eedd8a535786c8
This commit is contained in:
Bobby R. Bruce
2023-10-04 15:07:16 -07:00
parent ae104cc431
commit d1f9f98747
4 changed files with 17 additions and 105 deletions

View File

@@ -21,10 +21,10 @@ sudo apt-get install qemu libvirt-daemon-system libvirt-clients ebtables dnsmasq
sudo apt purge vagrant-libvirt
```
## Set up the Vagrantfiles for the GitHub repository
## Set up the Vagrant for the GitHub repository
First, generate a Personal Access Token, which you can create [here](https://github.com/settings/tokens)
Make sure to set admin permissions on this token, then replace instances of `<PERSONAL ACCESS TOKEN>` in the Vagrantfiles ("Vagrantfile-builder" and "Vagrant-runner") with your token.
Make sure to set admin permissions on this token, then replace the of `<PERSONAL ACCESS TOKEN>` in the Vagrantfile with your token.
Next, replace instances of `<GITHUB REPO>` with your GitHub account name and the repository name, separated by a forward slash.
For example, if your GitHub account name is `example` and your repository name is `example-repo`, you would replace `<GITHUB REPO>` with `example/example-repo`.
@@ -46,28 +46,19 @@ vagrant plugin install vagrant-libvirt
vagrant plugin install vagrant-reload
```
## The "builder" and "runner" VMs
The number of CPUs and the memory size differs between the "Vagrantfile-builder" and "Vagrantfile-runner".
In our work we have two types of machines "runners" and "builders".
Runners are single core machines with 8GB of memory, and builders are 4 core machines with 16GB of memory.
The latter is used for building gem5 binaries while the former is used for running instances of gem5.
You can expect each machine to take up approximately 60GB of disk space though VMs will consume the disk space they require.
The "Vagrantfile-builder" file is set to create a runner machine and the "Vagrantfile-builder" file is set to create a builder machine.
Specifying which Vagrantfile to use is done by setting the `VAGRANT_VAGRANTFILE` environment variable.
## Creating the virtual machine
The Vagrantfile in this directory defines a VM that can be used to create a GitHub Actions runner.
It has 4-cores, 16GB of RAM, and 60GB of disk space.
This is sufficient to both compile gem5 and run most simulations.
Each VM on your host system must have a unique name.
Give the VM to be created a unique name by setting the `<VM NAME>` variables in the Vagrantfile you wish to utilize.
Then run:
```sh
VAGRANT_VAGRANTFILE=<VAGRANTFILE> vagrant up --provider=libvirt
vagrant up --provider=libvirt
```
This should automatically create your machine, as well as configure and start up a Github Actions runner.
@@ -80,7 +71,7 @@ If you wish to create more than one runner you must edit the `<VM NAME>` in the
## Helper scripts
The "vm_manager" script can be used to set up multiple builder and runner VMs.
To use this script simply modify the `NUM_RUNNERS`, `NUM_BUILDERS`, `RUNNER_PREFIX`, and `BUILDER_PREFIX` variables to the desired values.
To use this script simply modify the `NUM_RUNNERS` and `RUNNER_PREFIX` variables to the desired values.
Then run the script with:
```sh

View File

@@ -13,23 +13,15 @@ Vagrant.configure("2") do |config|
config.vm.provider "libvirt" do |vb|
# Customize the amount of cpus and memory on the VM:
vb.cpus = "1".to_i
vb.memory = "8192".to_i
vb.cpus = "4".to_i
vb.memory = "16384".to_i
end
# sets up vm
config.vm.provision :shell, path: "provision_root.sh"
config.vm.provision :shell, privileged: false, path: "provision_nonroot.sh"
# To ensure we don't run out of memory, we enable dynamic Swap Space. This is
# done via the "swapspace" daemon: https://pqxx.org/development/swapspace/
config.vm.provision :shell, inline: "sudo apt install swapspace -y"
# The provision_root.sh adds the vagrant user to the docker group, so we need to reload the VM.
config.vm.provision :reload
config.vm.provision :shell, run: 'always', inline: <<-SHELL
# When running gem5 in SE mode we must overcommit memory.
# This is run on every startup of the VM.
/sbin/sysctl vm.overcommit_memory=1
SHELL
config.vm.provision :shell, privileged: false, run: 'always', inline: <<-SHELL
if [ -d ~/actions-runner ]; then
# This will be run everytime the VM is run (once created).

View File

@@ -1,57 +0,0 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "generic/ubuntu2204"
config.vm.box_check_update = true
config.vm.define "<VM NAME>"
config.vm.hostname = "<VM NAME>"
# allows us to ssh into the machine, addressing the problem below
# https://www.reddit.com/r/vagrant/comments/sb7hfl/new_to_vagrant_getting_efault_warning/
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
config.vm.provider "libvirt" do |vb|
# Customize the amount of cpus and memory on the VM:
vb.cpus = "4".to_i
vb.memory = "16384".to_i
end
# sets up vm
config.vm.provision :shell, path: "provision_root.sh"
config.vm.provision :shell, privileged: false, path: "provision_nonroot.sh"
# To ensure we don't run out of memory, we enable dynamic Swap Space. This is
# done via the "swapspace" daemon: https://pqxx.org/development/swapspace/
config.vm.provision :shell, inline: "sudo apt install swapspace -y"
# The provision_root.sh adds the vagrant user to the docker group, so we need to reload the VM.
config.vm.provision :reload
config.vm.provision :shell, run: 'always', inline: <<-SHELL
# When running gem5 in SE mode we must overcommit memory.
# This is run on every startup of the VM.
/sbin/sysctl vm.overcommit_memory=1
SHELL
config.vm.provision :shell, privileged: false, run: 'always', inline: <<-SHELL
if [ -d ~/actions-runner ]; then
# This will be run everytime the VM is run (once created).
cd actions-runner
nohup ./run.sh &
else
# This will be run the first time the VM is created.
mkdir ~/actions-runner && cd ~/actions-runner
curl -so actions-runner-linux-x64-2.304.0.tar.gz -L \
https://github.com/actions/runner/releases/download/v2.304.0/actions-runner-linux-x64-2.304.0.tar.gz
tar xzf ./actions-runner-linux-x64-2.304.0.tar.gz
# configure the runner
# echo automatically sets the name of the runner, and the tags
# create a personal access token with admin permission and copy it into the curl command
echo -ne '\n\nbuild\n\n' | ./config.sh --url https://github.com/<GITHUB REPO> --token $(curl -L \
-X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer <PERSONAL ACCESS TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/<GITHUB REPO>/actions/runners/registration-token | jq -r '.token')
# start the runner
nohup ./run.sh &
fi
SHELL
end

View File

@@ -1,9 +1,7 @@
#!/bin/bash
NUM_RUNNERS=20
NUM_BUILDERS=3
RUNNER_PREFIX="$(hostname)-runner-"
BUILDER_PREFIX="$(hostname)-builder-"
NUM_RUNNERS=3
RUNNER_PREFIX_PREFIX="$(hostname)"
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
export VAGRANT_HOME=${SCRIPT_DIR}
@@ -19,25 +17,13 @@ fi
for (( i=1; i<=NUM_RUNNERS; i++ )); do
sed -i "s/ config.vm.define.*/ config.vm.define \"${RUNNER_PREFIX}${i}\"/g" Vagrantfile-runner
sed -i "s/ config.vm.hostname.*/ config.vm.hostname = \"${RUNNER_PREFIX}${i}\"/g" Vagrantfile-runner
sed -i "s/ config.vm.define.*/ config.vm.define \"${RUNNER_PREFIX}-${i}\"/g" Vagrantfile
sed -i "s/ config.vm.hostname.*/ config.vm.hostname = \"${RUNNER_PREFIX}-${i}\"/g" Vagrantfile
if [[ "${param}" == "destroy" ]]; then
VAGRANT_VAGRANTFILE=Vagrantfile-runner vagrant destroy -f
VAGRANT_VAGRANTFILE=Vagrantfile vagrant destroy -f
elif [[ "${param}" == "shutdown" ]]; then
VAGRANT_VAGRANTFILE=Vagrantfile-runner vagrant halt -f
VAGRANT_VAGRANTFILE=Vagrantfile vagrant halt -f
else
VAGRANT_VAGRANTFILE=Vagrantfile-runner vagrant up --provider=libvirt
fi
done
for (( i=1; i<=NUM_BUILDERS; i++ )); do
sed -i "s/ config.vm.define.*/ config.vm.define \"${BUILDER_PREFIX}${i}\"/g" Vagrantfile-builder
sed -i "s/ config.vm.hostname.*/ config.vm.hostname = \"${BUILDER_PREFIX}${i}\"/g" Vagrantfile-builder
if [[ "${param}" == "destroy" ]]; then
VAGRANT_VAGRANTFILE=Vagrantfile-builder vagrant destroy -f
elif [[ "${param}" == "shutdown" ]]; then
VAGRANT_VAGRANTFILE=Vagrantfile-builder vagrant halt -f
else
VAGRANT_VAGRANTFILE=Vagrantfile-builder vagrant up --provider=libvirt
VAGRANT_VAGRANTFILE=Vagrantfile vagrant up --provider=libvirt
fi
done