Skip to content

Commit

Permalink
Wait for podman to be running
Browse files Browse the repository at this point in the history
  • Loading branch information
efrecon committed Feb 13, 2024
1 parent caefd6e commit 9166f03
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
19 changes: 19 additions & 0 deletions lib/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,25 @@ run_krunvm() {
buildah unshare krunvm "$@"
}

# Wait for a path to exist
# $1 is the test to perform, e.g. -f for file, -d for directory, etc.
# $2 is the path to wait for
# $3 is the timeout in seconds
# $4 is the interval in seconds
wait_path() {
_interval="${4:-1}"
_elapsed=0

while ! test "$1" "$2"; do
if [ "$_elapsed" -ge "${3:-60}" ]; then
error "Timeout waiting for $2"
fi
_elapsed=$((_elapsed+_interval))
sleep "$_interval"
debug "Waiting for $2"
done
}

# PML: Poor Man's Logging
_log() {
# Capture level and shift it away, rest will be passed blindly to printf
Expand Down
5 changes: 3 additions & 2 deletions runner/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ RUNNER_PAT=${RUNNER_PAT:-""}
RUNNER_EPHEMERAL=${RUNNER_EPHEMERAL:-"0"}

# Root installation of the runner
RUNNER_INSTALL=${RUNNER_INSTALL:-"$RUNNER_ROOTDIR/../share/runner"}
RUNNER_INSTALL=${RUNNER_INSTALL:-"/opt/gh-runner-krunvm/share/runner"}

# Should the runner auto-update
RUNNER_UPDATE=${RUNNER_UPDATE:-"0"}
Expand Down Expand Up @@ -255,7 +255,8 @@ docker_daemon() {
# Start podman as a service, make sure it can be accessed by the runner
# user.
verbose "Starting $podman as a daemon"
runas "$podman" system service --time=0 unix:///var/run/docker.sock &
"$podman" system service --time=0 unix:///var/run/docker.sock &
wait_path -S "/var/run/docker.sock" 60
# Arrange for members of the docker group, which the runner user is a member
# to be able to access the socket.
chgrp "docker" /var/run/docker.sock
Expand Down

0 comments on commit 9166f03

Please sign in to comment.