Repository navigation
Docker: allow to be used from NIPA with rootless podman - #139
Merged
Merged
Conversation
This message is useful when the script is used interactively, but it is just noise when the output is parsed, e.g. by contest/remote/lib/vm.py when 'vng' is executed from the container. Signed-off-by: Matthieu Baerts <matttbe@kernel.org>
Directories passed as arguments are mounted, but not when they are passed as values, e.g. 'make O=<dir>', 'INSTALL_PATH=<dir>', or '--opt=<dir>'. That's needed to wrap 'make' with this script when executing contest/remote/vmksft-p.py: get_prog_list() installs the selftests in a temp dir created on the host with 'INSTALL_PATH=<dir>', then reads the generated kselftest-list.txt file from there. Without this mount, the file would only be created inside the container. Signed-off-by: Matthieu Baerts <matttbe@kernel.org>
To easily execute some commands from the selftests container instead of the host, e.g. 'make' and 'vng' when executing contest/remote/vmksft-p.py to use the toolchain, QEMU and virtme-ng from the container: symlinks named after these commands and pointing to this wrapper can be placed in a directory at the beginning of $PATH. This wrapper is not a symlink to a common script, because it would then be resolved by 'realpath', and the wrong image would be used. Signed-off-by: Matthieu Baerts <matttbe@kernel.org>
When the Docker client is killed with SIGKILL, the container is not stopped. This is what contest/remote/lib/vm.py does when a VM doesn't stop: all its processes are killed with SIGKILL. When 'vng' is executed from a container, QEMU then continues to run in the background, using CPU and memory resources. Such signal cannot be trapped, nor forwarded by the client. Instead, a detached process -- so not part of the killed process tree -- waits for the client to be gone, then removes the container, identified by a new unique name. This process also removes the container if it is asked to stop, e.g. when all processes of a systemd service are terminated. This watchdog is not started if one of the commands it uses is wrapped with wrapper.sh: it would call itself recursively. A warning is printed instead. While at it, the client is now started with 'exec': the signals sent to the script's PID are then received by the client, which forwards them to the container. '--init' is now used to avoid having these signals ignored by the command, executed as PID 1 in the container otherwise. Signed-off-by: Matthieu Baerts <matttbe@kernel.org>
The extra paths from '[env] paths' were appended to $PATH: they could then not be used to override commands from the host, e.g. to execute 'make' and 'vng' from a container via docker/selftests/wrapper.sh. Prepend them instead, like it is already done in contest/remote/exec.py. Signed-off-by: Matthieu Baerts <matttbe@kernel.org>
The output of the container is sent to the attached client, but it is also sent to a log driver by default. Depending on the config, it is then written a second time to the disk -- 'json-file', without size limit by default -- or to the journal -- 'journald', the default with Podman -- where it is kept after the removal of the container. That's not needed here: the output is only used via the client, and the container is removed at the end. That's also not wanted when executing 'vng' from the container: the whole serial console of each VM would be duplicated. Signed-off-by: Matthieu Baerts <matttbe@kernel.org>
With rootless Podman, the user's UID is mapped to root in the container by default, and '-u $(id -u)' is then mapped to another UID on the host, which cannot write to the mounted directories, e.g. the kernel tree. '--userns=keep-id' fixes that by keeping the same UID/GID in the container. Podman uses the PODMAN_USERNS environment variable as the default value for this option, while Docker ignores it: the same script can then be used with both, e.g. with Podman via the podman-docker package providing the 'docker' command. This is only done for non-root users, not to change the behaviour with rootful Podman. Signed-off-by: Matthieu Baerts <matttbe@kernel.org>
The scripts can be used with Podman, via the 'docker' command provided by the podman-docker package. With rootless Podman, '--userns=keep-id' is set by the scripts, but it has to be added when using Podman directly, to be able to write to the mounted directories. When used from a systemd service with 'User=', lingering has to be enabled for this user, and the unit has to set its runtime directory: Podman can then use the user's systemd instance, e.g. to manage the containers' cgroups, without printing warnings at each call. Signed-off-by: Matthieu Baerts <matttbe@kernel.org>
Member
Author
|
Exceptionally merging without review to deploy this workaround. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A few modifications to run the docker images from nipa with Podman