Skip to content

Commit 170371c

Browse files
authored
Reworks container support (#741)
This PR reworks the tool-suites container support. The main changes are: * Base images are now separated into stages. This allows rebuilding only certain stages. * vara-container build has additional flags for updating only varats, the research tool, or the config. * Installing research tools into a container is handled by a new protocol * vara-container prepare-slurm has been removed. Its functionality is now handled by vara-run. As a side-effect, this does no longer require persistent changes to the benchbuild config. * node_dir cleanup in the slurm script template has (hopefully) been fixed * Container-related config has been updated. * Python 3.10 in the Debian 10 base image
1 parent 9ff72b7 commit 170371c

23 files changed

+862
-684
lines changed

docs/source/tutorials/container_guide.rst

+14-11
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@ Container Guide
33

44
VaRA-TS supports running experiments inside containers to make them more portable and reproducible.
55
This guide walks you through the steps how to prepare and execute experiments in containers and assumes that your system has already been set up for executing containers.
6-
You can find the instructions for setting up containers on your system :ref:`here <Running BenchBuild in a Container>`.
7-
More details about the inner workings of the container support in VaRA-TS can be found :ref:`here <Container support>`.
6+
For additional resources, see the following pages:
7+
8+
- :ref:`Running BenchBuild in a Container` explains how to initially set up containers on your system and how they work with BenchBuild under the hood.
9+
- :ref:`Container support` explains how VaRA-TS creates and manages reusable base images that can be used by projects.
10+
- :ref:`vara-container` is the tool that is used for managing these base images.
11+
- :ref:`Using Containers` explains how container support can be implemented for a project.
12+
- :ref:`Slurm and Container` demonstrates the container support integration with slurm.
13+
14+
15+
816
Note that, by default, the most recent version of VaRA-TS available from PyPI will be used inside the container.
917
If you want to use your local development version of VaRA-TS instead, you have to specify this in the ``.varats.yml`` configuration file by setting the value of ``from_source`` to true and the value of ``varats_source`` to the directory containing the source code of the VaRA-TS.
1018

@@ -18,11 +26,12 @@ If you want to use your local development version of VaRA-TS instead, you have t
1826
vara-buildsetup build vara --container=DEBIAN_10
1927
2028
Note that the underlying tools may not support network file systems (i.e., if you are using podman in `rootless mode <https://github.com/containers/podman/blob/master/rootless.md>`_).
21-
In the ``.benchbuild.yml`` configuration, you need to set the values of ``root`` and ``runroot`` to a directory that is locally available on the current machine.
29+
In the ``.benchbuild.yml`` configuration, you need to set the values of ``container/root`` and ``container/runroot`` to a directory that is locally available on the current machine.
2230
For example, you can use the following values:
2331

2432
.. code-block:: yaml
2533
34+
container:
2635
root:
2736
default: !create-if-needed '/scratch/<username>/vara-root/benchbuild/containers/lib'
2837
desc: Permanent storage for container images
@@ -50,6 +59,8 @@ If you want to use your local development version of VaRA-TS instead, you have t
5059
vara-container build
5160
5261
You can use the flag ``-i <base_image>`` to only build a specific base image and should add ``--export`` if you want to use the image with slurm.
62+
There are also flags for re-building only parts of an image, e.g., to just update the tool suite.
63+
These flags can drastically remove the time it takes to build an image.
5364

5465
3. Running the experiments
5566

@@ -58,11 +69,3 @@ If you want to use your local development version of VaRA-TS instead, you have t
5869
.. code-block:: console
5970
6071
vara-run -E JustCompile --container
61-
62-
Do not forget to run
63-
64-
.. code-block:: console
65-
66-
vara-gen-bbconfig
67-
68-
and to adapt the values as described in step 1 before running your experiments.

docs/source/vara-ts-api/containers.rst

+16-7
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
Container support
22
=================
33

4-
BenchBuild allows you to :ref:`run experiments in a container <Running BenchBuild in a container>`.
5-
The `containers` module handles the correct creation of container images.
6-
Our containers are structured in layers as follows::
4+
VaRA-TS allows you to :ref:`run experiments in a container <Container Guide>`.
5+
The ``containers`` module handles the correct creation of container images.
6+
Our container images are structured in multiple stages as follows::
77

88
┌───────────────────────────────────┐ \
9+
│ Stage 00 │ |
910
│ Base Container (e.g., Debian 10) │ |
11+
│ + dependencies │ |
1012
└───────────────────────────────────┘ |
1113
+ |
1214
┌───────────────────────────────────┐ |
13-
│ varats │ |
15+
│ Stage 10 │ |
16+
│ varats/benchbuild │ |
1417
└───────────────────────────────────┘ |
1518
+ > Base Image
1619
┌───────────────────────────────────┐ |
17-
│ benchbuild │ |
20+
│ Stage 20 │ |
21+
│ Research Tool (e.g., VaRA) │ |
1822
└───────────────────────────────────┘ |
1923
+ |
2024
┌───────────────────────────────────┐ |
21-
│ Research Tool (e.g., VaRA) │ |
25+
│ Stage 30 │ |
26+
│ configuration │ |
2227
└───────────────────────────────────┘ /
2328
+
2429
┌───────────────────────────────────┐
@@ -30,6 +35,10 @@ Our containers are structured in layers as follows::
3035
└───────────────────────────────────┘
3136

3237

38+
Each stage results in its own container image.
39+
This allows us to update only some of the stages to save time when only changes to certain stages are required (especially stage 00 can be very time consuming to build).
40+
The :ref:`vara-container` tool provides appropriate command line flags to only re-build certain stages.
41+
3342
Base images are built once for each :class:`~varats.containers.containers.ImageBase` with the currently configured research tool using the :ref:`vara-container` tool.
3443
Projects must :ref:`select one of these base images <Using Containers>` which they are then free to extend with their own project-specific dependencies.
3544
The directory structure inside a container looks like the following::
@@ -41,7 +50,7 @@ The directory structure inside a container looks like the following::
4150
├─ BC_files/ # mount point to <varats-root>/benchbuild/BC_files outside the container
4251
└─ paper_configs/ # mount point to <varats-root>/paper_configs outside the container
4352

44-
See :ref:`Running BenchBuild in a container` for how to set up the mount points.
53+
The required mount points are specified automatically when creating a BenchBuild config via :ref:`vara-gen-bbconfig`.
4554

4655
Containers module
4756
.................

docs/source/vara-ts-api/projects.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ environment).
197197
Using Containers
198198
................
199199

200-
To use :ref:`BenchBuild's container support <Running BenchBuild in a container>`, a project has to declare what container image to use.
200+
To use a project with our :ref:`container support <Container Guide>` it has to declare which container image to use.
201201
This can be done by assigning a container image to the `CONTAINER` class variable::
202202

203203
CONTAINER = get_base_image(ImageBase.DEBIAN_10)
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
vara-container
22
==============
33

4-
This tool is used to manage the base container images used when :ref:`running benchbuild in container mode<Running BenchBuild in a container>`.
4+
This tool is used to manage the base container images used when using our :ref:`container support<Container Guide>`.
55

66
.. program-output:: vara-container -h
77
:nostderr:
@@ -11,7 +11,8 @@ This tool provides an easy way to select the research tool that is used in the b
1111
.. program-output:: vara-container select -h
1212
:nostderr:
1313

14-
With `vara-container build`, you can build all base container images for the current research tool:
14+
With `vara-container build`, you can build all base container images for the current research tool.
15+
Additional flags allow to only re-build parts of the base image.
1516

1617
.. program-output:: vara-container build -h
1718
:nostderr:
@@ -25,16 +26,3 @@ Existing base images can also be deleted:
2526

2627
This command does not delete project and experiment images, it only deletes base images.
2728
To delete project and experiment images use BenchBuild's `benchbuild container rmi` command.
28-
29-
30-
If you plan on running BenchBuild with container support on slurm, the following command helps you set up the correct environment:
31-
32-
.. program-output:: vara-container prepare-slurm -h
33-
:nostderr:
34-
35-
36-
.. warning::
37-
This command changes the location where container images are built and stored in the BenchBuild config.
38-
That means that all subsequent container images will reside in that directory including the base images that are built by this command.
39-
This also means, that the ``--node_dir`` option you pass to this command must be a path that can be created on both, the machine where this command is executed and on the slurm nodes.
40-
In general, it is a good idea to use some subdirectory of ``/tmp`` here, although that means that images and containers may be lost after a reboot.

docs/source/vara-ts/benchbuild.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,10 @@ Using buildah and podman on the Commandline
189189
...........................................
190190

191191
For more advanced users, it might be useful to work with buildah and podman directly from the commandline, e.g., when debugging container images.
192-
In these situations, it can come in handy to create some shell aliases that set the correct `root` and `runroot` to for the buildah and podman commands::
192+
In these situations, it can come in handy to create some shell aliases that set the correct `root` and `runroot` to for the buildah and podman commands, as well as the `storage_driver` that is set in BenchBuild's config file::
193193

194-
alias bbuildah='buildah --root $VARATS_ROOT/containers/lib --runroot $VARATS_ROOT/containers/run'
195-
alias bpodman='podman --root $VARATS_ROOT/containers/lib --runroot $VARATS_ROOT/containers/run'
194+
alias bbuildah='buildah --root $VARATS_ROOT/containers/lib --runroot $VARATS_ROOT/containers/run --storage-driver=vfs'
195+
alias bpodman='podman --root $VARATS_ROOT/containers/lib --runroot $VARATS_ROOT/containers/run --storage-driver=vfs'
196196

197197

198198
Debugging Container Images
@@ -226,7 +226,7 @@ As an alternative, you can also mount the file system of a container image by fo
226226

227227
.. code-block:: bash
228228
229-
newontainer=$(bbuildah from <image_id>)
229+
newcontainer=$(bbuildah from <image_id>)
230230
231231
This command will print a container id.
232232
4. Mount the working container (identified by the id you got from the step before) with

docs/source/vara-ts/slurm.rst

+21-33
Original file line numberDiff line numberDiff line change
@@ -108,52 +108,42 @@ If you understand how BenchBuild uses containers to run experiments you can prep
108108

109109
1. Set up VaRA-TS as described in the normal :ref:`slurm guide <Running with Slurm>` (steps 1 and 2).
110110

111-
2. Set up the BenchBuild container support as described in the :ref:`BenchBuild container documentation <Running BenchBuild in a Container>`.
111+
2. Make sure that the host systems (from where slurm jobs are submitted), as well as the slurm cluster has rootless buildah and podman installed and configured (don't forget the subuid and subgid mappings for the users submitting the slurm jobs).
112+
See :ref:`Running BenchBuild in a Container` for further instructions.
112113

113-
3. Make sure that also the slurm cluster has rootless buildah and podman installed and configured (don't forget the subuid and subgid mappings for the users submitting the slurm jobs).
114+
3. Prepare the research tool(s) and base images (see the :ref:`container guide<Container Guide>`).
115+
Use the ``--export`` flag when generating the base images to make them available to the containers running via slurm.
114116

115-
4. Preparing the research tool(s) for each base container required by your experiments, e.g.:
116-
117-
.. code-block:: console
118-
119-
vara-buildsetup build vara --container=DEBIAN_10
120-
121-
5. Rootless containers do not work on NFS (see `here <https://github.com/containers/podman/blob/master/rootless.md>`_), so we have to take some extra steps if we want to run containers via slurm.
122-
These steps can be executed easily using the following command (:ref:`documentation <vara-container>`):
123-
124-
.. code-block:: bash
125-
126-
vara-container prepare-slurm
127-
128-
This step also builds the base images.
129-
130-
If you want to know in detail what happens in this command, take a look at the section :ref:`Prepare-Slurm in Detail`.
131-
132-
6. After the preparation is complete, you can generate the slurm script as follows:
117+
4. After the preparation is complete, you can generate the slurm script as follows:
133118

134119
.. code-block:: bash
135120
136121
vara-run --slurm --container -E <report_type> <projects>
137122
138-
7. That's it! the script obtained from the previous step can be used like any other slurm script.
123+
5. That's it! the script obtained from the previous step can be used like any other slurm script.
139124
You can now make any adjustments to the script if needed or just submit it to slurm as described in the slurm guide (step 5).
140125
You can also add the flag ``--submit`` to the ``vara-run`` command to directly submit the script to slurm.
141126

142127

143-
Prepare-Slurm in Detail
144-
...........................
128+
How vara-run handles rootless containers
129+
........................................
130+
131+
.. note::
132+
133+
This section is mainly for documentation purposes and intended for advanced users and developers of VaRA-TS.
145134

146-
As explained above, rootless containers do not work on NFS (see `here <https://github.com/containers/podman/blob/master/rootless.md>`_), so we have to take some extra steps if we want to run containers via slurm.
147-
The recommended way to do this is using the ``vara-container prepare-slurm`` command, but in some situations it might be handy to know what happens under the hood:
135+
Rootless containers do not work on NFS (see `here <https://github.com/containers/podman/blob/master/rootless.md>`_), so we have to take some extra steps if we want to run containers via slurm.
136+
These steps are handled automatically by ``vara-run`` but in some situations it might be handy to know what happens under the hood:
148137

149-
- You need to set the container root and runroot paths to some location that is not on a NFS, e.g., to a directory in ``tmp``:
138+
- You need to set the container root and runroot paths to some location that is not on a NFS, e.g., to a directory in ``tmp``.
139+
Since this may differ from your local setup, BenchBuild offers its own set of configuration options to set the buildah/podman root and runroot directories on slurm:
150140

151141
.. code-block:: yaml
152142
153-
container:
154-
root:
143+
slurm:
144+
container_root:
155145
value: /tmp/<username>/containers/lib
156-
runroot:
146+
container_runroot:
157147
value: /tmp/<username>/containers/run
158148
159149
- BenchBuild allows to export and import container images.
@@ -192,14 +182,12 @@ The recommended way to do this is using the ``vara-container prepare-slurm`` com
192182

193183
- Now it is time to generate the slurm script (cf. step 5 of the slurm guide).
194184
Because of our NFS workarounds, we cannot use the default script provided by BenchBuild, but we need to provide our own script template.
195-
You can find our default template in the ``varats.tools`` module.
196-
This template is very similar to the original template provided by BenchBuild, but it takes care of pointing all relevant environment variables to the slurm node directory as described in the points above.
185+
You can find our default template in the ``varats.tools.templates`` module.
186+
This template is very similar to the original template provided by BenchBuild, but it takes care of pointing all relevant environment variables to the slurm node directory as described in the points above and implements a different cleanup strategy for the node directory.
197187
To activate the template, simply save it to the ``/scratch/<username>/varats/benchbuild`` directory and set the appropriate value in the BenchBuild config:
198188

199189
.. code-block:: yaml
200190
201191
slurm:
202192
template:
203193
value: /scratch/<username>/varats/benchbuild/slurm_container.sh.inc
204-
205-
You can now continue with generating the slurm script as described above.

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
argparse-utils>=1.2.0
2-
benchbuild>=6.6.3
2+
benchbuild>=6.6.4
33
click>=8.0.2
44
distro>=1.5.0
55
graphviz>=0.14.2

0 commit comments

Comments
 (0)