Skip to content
Snippets Groups Projects

gitlab_runner: Add VM based executor (libvirt-executor)

Merged Kristian Klausen requested to merge klausenbusk/infrastructure:custom-executor into master
Compare and Show latest version
1 file
+ 7
11
Compare changes
  • Side-by-side
  • Inline
#!/usr/bin/evn bash
#!/usr/bin/env bash
set -o nounset -o errexit -o pipefail
readonly MIRROR="https://mirror.pkgbuild.com"
readonly LIBVIRT_DEFAULT_POOL_PATH="/var/lib/libvirt/images"
@@ -9,7 +9,7 @@ ssh() {
}
get_vm_ip() {
if [[ -z ${vm_ip-} ]]; then
if [[ -z "${vm_ip-}" ]]; then
vm_ip="$(virsh -q domifaddr "${1}" | awk -F'[ /]+' '{print $5}')"
[[ -n "${vm_ip}" ]] || return 1
fi
@@ -22,10 +22,6 @@ get_vm_name() {
wait_for_ssh() {
for i in {1..90}; do
if [ "${i}" -eq 90 ]; then
echo 'Waited 90 seconds for VM to start, exiting...'
exit "${SYSTEM_FAILURE_EXIT_CODE:-1}"
fi
if ! get_vm_ip "${1}"; then
echo "Waiting for network"
sleep 1
@@ -36,20 +32,20 @@ wait_for_ssh() {
sleep 1
continue
fi
break
return 0
done
echo 'Waited 90 seconds for VM to start, exiting...'
exit "${SYSTEM_FAILURE_EXIT_CODE:-1}"
}
wait_for_vm_shutdown() {
for i in {1..10}; do
if [ "${i}" -eq 60 ]; then
return 1
fi
if LC_ALL=C virsh domstate "${1}" | grep -F "shut off"; then
break
return 0
fi
sleep 1
done
return 1
}
# Create a updated VM image with the required tools
Loading