mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-22 01:13:00 +02:00
When a test starts an isolated MACVLAN namespace, it is often useful
to interactively join that namespace to investigate issues. To do
this, we need to find the "sleeper" process backing the namespace, and
`nsenter` into that process's network namespace.
Add a script that automates this process.
To start a shell in the netns of the MACVLAN stacked on top of d1b,
start a shell in the test environment:
infix/test $ ./shell
13:37:00 infamy0:test # ./nsenter d1b
13:37:01 infamy0(netns:d1b):test #
41 lines
791 B
Bash
41 lines
791 B
Bash
# Set $testdir before sourcing these envs -*-shell-script-*-
|
|
# shellcheck disable=SC2034,SC2154
|
|
|
|
# Current container image
|
|
INFIX_TEST=ghcr.io/kernelkit/infix-test:1.3
|
|
|
|
ixdir=$(readlink -f "$testdir/..")
|
|
logdir=$(readlink -f "$testdir/.log")
|
|
envdir="$HOME/.infix-test-venv"
|
|
qeneth="$testdir/qeneth/qeneth"
|
|
|
|
build_ps1()
|
|
{
|
|
echo "\e[1m\$(date \"+%H:%M:%S\") \h$1\e[0m:\W # "
|
|
}
|
|
|
|
#
|
|
# Figure out available container runner
|
|
#
|
|
runner()
|
|
{
|
|
if which podman >/dev/null; then
|
|
runner=podman
|
|
elif which docker >/dev/null; then
|
|
runner=docker
|
|
else
|
|
echo "Error: Neither podman or docker is installed, we recommend podman."
|
|
exit 1
|
|
fi
|
|
|
|
echo "$runner"
|
|
}
|
|
|
|
#
|
|
# Returns the latest started infamy container
|
|
#
|
|
infamy()
|
|
{
|
|
$(runner) ps -f name='infamy.*' --format '{{.Names}}' |tail -1
|
|
}
|