Skip to content

Commit

Permalink
Move (not unpack) runner directory
Browse files Browse the repository at this point in the history
  • Loading branch information
efrecon committed Feb 16, 2024
1 parent 553de6c commit a0b3a08
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
18 changes: 18 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,21 @@ automatically removed as soon as the microVM has booted is running the
`runner.sh` script, workflows are not able to break the external loop: they are
able to create files in the `/_environment` directory, but they cannot know the
value of the secret to put into the file to force the exiting handshake.

## Changes to the Installation Scripts

The installation of both images is handled by the [`base.sh`](./base/base.sh)
and [`install.sh`](./runner/install.sh). When making changes to these scripts,
or to the [`docker.sh`](./base/docker.sh) docker CLI wrapper, you will need to
wait for the results of the [`dev.yml`](./.github/workflows/dev.yml) workflow to
finish and for the resulting image to be published at the GHCR before being able
to test. The images will be published for amd64 only and with a tag named after
the name of the branch. Check out the "Inspect image" step of the `merge` job to
collect the fully-qualified name of the image. Once done, provide that name to
the `-i` option of the [`orchestrator.sh`](./orchestrator.sh) script.

Note that when changing the logic of the "entrypoints", i.e. the scripts run at
microVM initialisation, you do not need to wait for the image to be created.
Instead, pass `-D /local` to the [`orchestrator.sh`](./orchestrator.sh) script.
This will mount the [`runner`](./runner/) directory into the microVM at `/local`
and run the scripts that it contains from there instead.
30 changes: 23 additions & 7 deletions runner/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ RUNNER_EPHEMERAL=${RUNNER_EPHEMERAL:-"0"}
# Root installation of the runner
RUNNER_INSTALL=${RUNNER_INSTALL:-"/opt/gh-runner-krunvm/share/runner"}

# Permit several installations
RUNNER_MULTI=${RUNNER_MULTI:-"0"}

# Should the runner auto-update
RUNNER_UPDATE=${RUNNER_UPDATE:-"0"}

Expand Down Expand Up @@ -153,13 +156,22 @@ KRUNVM_RUNNER_BIN="${KRUNVM_RUNNER_BIN%.sh}-$RUNNER_ID"
# minimal verification of the installation through checking that there is a
# config.sh script executable within the copy.
runner_install() {
# Make a directory where to install a copy of the runner.
if ! [ -d "${RUNNER_WORKDIR%/}/runner" ]; then
mkdir -p "${RUNNER_WORKDIR%/}/runner"
verbose "Created runner directory ${RUNNER_WORKDIR%/}/runner"
if [ "$RUNNER_MULTI" = 1 ]; then
# Make a directory where to install a copy of the runner.
if ! [ -d "${RUNNER_WORKDIR%/}/runner" ]; then
mkdir -p "${RUNNER_WORKDIR%/}/runner"
verbose "Created runner directory ${RUNNER_WORKDIR%/}/runner"
fi
verbose "Installing runner in ${RUNNER_WORKDIR%/}/runner"
tar -C "${RUNNER_WORKDIR%/}/runner" -zxf "$RUNNER_TAR"
else
if ! [ -d "${RUNNER_WORKDIR%/}" ]; then
mkdir -p "${RUNNER_WORKDIR%/}"
verbose "Created runner directory ${RUNNER_WORKDIR%/}"
fi
verbose "Moving runner installation to ${RUNNER_WORKDIR%/}/runner"
mv -f "$RUNNER_INSTDIR" "${RUNNER_WORKDIR%/}/runner" 2>/dev/null
fi
verbose "Installing runner in ${RUNNER_WORKDIR%/}/runner"
tar -C "${RUNNER_WORKDIR%/}/runner" -zxf "$RUNNER_TAR"
check_command "${RUNNER_WORKDIR%/}/runner/config.sh"
}

Expand Down Expand Up @@ -367,10 +379,14 @@ else
RUNNER_LABELS=${RUNNER_LABELS:-"krunvm"}
fi

RUNNER_TAR=$(find "$RUNNER_INSTALL" -type f -name "*.tgz" | sort -r | head -n 1)
RUNNER_TAR=$(find_pattern "${RUNNER_INSTALL}/*.tgz" f | sort -r | head -n 1)
if [ -z "$RUNNER_TAR" ]; then
error "No runner tar file found under $RUNNER_INSTALL"
fi
RUNNER_INSTDIR=$(find_pattern "${RUNNER_INSTALL}/runner-*" d | sort -r | head -n 1)
if [ -z "$RUNNER_INSTDIR" ]; then
error "No runner installation directory found under $RUNNER_INSTALL"
fi

# Construct the runner URL, i.e. where the runner will be registered
RUNNER_SCOPE=$(to_lower "$RUNNER_SCOPE")
Expand Down

0 comments on commit a0b3a08

Please sign in to comment.