-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an explicit ENTRYPOINT to the Agent "all" containers (#3320)
The containers will now execute a script which sources the agent/profile and then executes the requested command. Also, add two scripts to contrib/ one which wraps the container to make it easier to use and a demo script which shows how the wrapper might be used.
- Loading branch information
Showing
4 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
# This script is the entrypoint for the Agent containers. | ||
# | ||
# Since execution in these environments does not follow the normal login path, | ||
# we first execute the `agent/profile` script to set up the environment for | ||
# Agent commands. Then we exec the requested command. | ||
|
||
source /opt/pbench-agent/profile | ||
|
||
exec "${@}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#! /bin/bash | ||
# | ||
# This script is a wrapper to facilitate the invocation of a Pbench Agent | ||
# command using a containerized deployment of the Pbench Agent. Simply prefix | ||
# a Pbench Agent command line with the path to this script to run it inside a | ||
# container, without needing to install the Agent on the host system. | ||
# | ||
# Invocation options are provided as environment variables: | ||
# PB_AGENT_IMAGE_NAME: the full image name for the containerized Pbench Agent | ||
# _PBENCH_AGENT_CONFIG: the location of the Pbench Agent configuration file | ||
# PB_AGENT_RUN_DIR: the directory for use as the Pbench Agent "run directory" | ||
# PB_AGENT_SERVER_LOC: the host and port for the Pbench Server | ||
# PB_AGENT_PODMAN_OPTIONS: Additional options to be supplied to Podman run | ||
# | ||
# In all cases, reasonable defaults are supplied if the environment variables | ||
# are not defined. | ||
# | ||
# This script checks for the presence of a `~/.ssh` directory, an existing | ||
# Pbench Agent configuration file, and a Pbench Agent "run directory" and maps | ||
# them into the container if they exist. If the configuration file is missing | ||
# but the location of the Pbench Server is available, then this script will | ||
# generate the configuration file, and the script creates the run directory if | ||
# it does not exist. The script then invokes the Pbench Agent container with | ||
# these options and any others which the user has specified and passes in the | ||
# command to be executed. | ||
|
||
image_name=${PB_AGENT_IMAGE_NAME:-quay.io/pbench/pbench-agent-all-centos-8:latest} | ||
config_file=${_PBENCH_AGENT_CONFIG:-${HOME}/.config/pbench/pbench-agent.cfg} | ||
pbench_run_dir=${PB_AGENT_RUN_DIR:-/var/tmp/${USER}/pbench-agent/run} | ||
pbench_server=${PB_AGENT_SERVER_LOC} | ||
other_options=${PB_AGENT_PODMAN_OPTIONS} | ||
|
||
if [[ $# == 0 || $1 == "help" || $1 == "-h" || $1 == "--help" ]]; then | ||
echo "Usage: ${0} <Pbench Agent Command> [<arg>...]" >&2 | ||
exit 2 | ||
fi | ||
|
||
if [[ -d "${HOME}/.ssh" && -r "${HOME}/.ssh" ]]; then | ||
other_options="-v ${HOME}/.ssh:/root/.ssh:z ${other_options}" | ||
fi | ||
|
||
if [[ -f "${config_file}" && -r "${config_file}" ]]; then | ||
other_options="-v ${config_file}:/opt/pbench-agent/config/pbench-agent.cfg:z ${other_options}" | ||
elif [[ -n "${pbench_server}" ]]; then | ||
echo "Warning: the Pbench Agent config file is missing; attempting to generate one in ${config_file}" >&2 | ||
# TODO: this should be handled by a separate Pbench Agent command which | ||
# provides a "configuration wizard". | ||
mkdir -p $(dirname ${config_file}) | ||
cat > ${config_file} <<- EOF | ||
[DEFAULT] | ||
pbench_install_dir = /opt/pbench-agent | ||
pbench_web_server = ${pbench_server} | ||
[config] | ||
path = %(pbench_install_dir)s/config | ||
files = pbench-agent-default.cfg | ||
EOF | ||
else | ||
echo "Warning: the Pbench Agent config file (e.g., ${config_file}) is missing or inaccessible -- using default configuration." >&2 | ||
fi | ||
|
||
mkdir -p ${pbench_run_dir} | ||
other_options="-v ${pbench_run_dir}:/var/lib/pbench-agent:z ${other_options}" | ||
|
||
podman run \ | ||
-it \ | ||
--rm \ | ||
--network host \ | ||
--name pbench-agent \ | ||
${other_options} \ | ||
${image_name} "${@}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#! /bin/bash -xe | ||
# | ||
# This script provides a demonstration of the contrib/containerized-pbench/pbench | ||
# wrapper script. | ||
# | ||
|
||
#+ | ||
# Set up a few things to make life simpler. Typically, these would already be | ||
# set in the users environment (e.g., the `pbench` command alias would be done | ||
# by the user's login script; we wouldn't need the `shopt` command if these | ||
# commands were being run interactively; and, we only need `PB_AGENT_IMAGE_NAME` | ||
# here because we're not using the default image). | ||
#- | ||
shopt -s expand_aliases | ||
alias pbench=$(git rev-parse --show-toplevel)/contrib/containerized-pbench/pbench | ||
|
||
FIOTEST=${PWD}/fiotest | ||
export PB_AGENT_PODMAN_OPTIONS="--pull newer -v ${FIOTEST}:/fiotest:z" | ||
export PB_AGENT_IMAGE_NAME=quay.io/pbench/pbench-agent-all-fedora-36:main | ||
|
||
mkdir -p ${FIOTEST} | ||
|
||
#+ | ||
# Run the demo! | ||
#- | ||
pbench pbench-register-tool-set light | ||
pbench pbench-list-tools | ||
pbench pbench-user-benchmark --config example-workload -- \ | ||
fio --directory=/fiotest --name fio_test_file --direct=1 --rw=randread \ | ||
--bs=16k --size=100M --numjobs=16 --time_based --runtime=20s \ | ||
--group_reporting --norandommap | ||
pbench pbench-generate-token --output=/var/lib/pbench-agent/.token | ||
pbench pbench-results-move --token=$(< /var/tmp/pbench/pbench-agent/run/.token) |