Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oci: fallback to fuse-overlayfs if kernel doesn't support unprivileged overlays and oci: support for writable extfs img overlay via fuse-overlayfs, from sylabs 1730 & 1740 #335

Closed
wants to merge 115 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
193d25b
refactor: Launcher to interface & native.Launcher
dtrudg Oct 10, 2022
c4548b5
launcher: add placeholder OCI launcher
dtrudg Oct 10, 2022
dffd2c8
actions: Add --oci flag to call OCI launcher
dtrudg Oct 11, 2022
d62fe20
launcher: fix OCI launcher supported option checks
dtrudg Oct 11, 2022
99f68e8
oci: switch to runc for oci commands
dtrudg Feb 24, 2022
00db0c7
oci: remove singularity oci_engine
dtrudg Feb 28, 2022
e604c9a
oci: add conmon for detached flow
dtrudg Feb 25, 2022
fed0ed9
oci: use FindBin for conmon, runc
dtrudg Feb 28, 2022
0cd88c2
oci: Update LICENSE docs and copyright lines
dtrudg Feb 28, 2022
3df5cf6
e2e: adapt oci help text
dtrudg Feb 28, 2022
5eb1db0
oci: fix: ensure `oci exec` calls runc and e2e test checks this
dtrudg Mar 9, 2022
7952c83
oci: simplify AttachStreams type
dtrudg Mar 9, 2022
3d24eb1
oci: chore: update missed copyright headers
dtrudg Mar 9, 2022
588249e
refactor: Move runc/conmon functionality out of app/singularity
dtrudg Oct 25, 2022
955e9fb
feat: run action for OCI bundle
dtrudg Oct 27, 2022
d5a958f
e2e: oci: add subtests, move help to parallel
dtrudg Nov 1, 2022
e6e9271
chore(ci): use crun 1.6
dtrudg Nov 1, 2022
7daac21
feat: run OCI image sources via temporary bundle
dtrudg Nov 14, 2022
b4a31ab
test: Add native OCI bundle verification test
dtrudg Nov 15, 2022
365100d
e2e: test for run --oci from oci sources
dtrudg Nov 15, 2022
7bd5910
chore: refactor native bundle to functional options
dtrudg Nov 16, 2022
f28acf7
feat: exec / run args support for --oci mode
dtrudg Nov 16, 2022
e143519
fix: return exit code from OCI launcher
dtrudg Nov 16, 2022
fcacb62
e2e: test --oci run/exec with args
dtrudg Nov 16, 2022
24c9783
feat: enable shell for --oci mode
dtrudg Nov 18, 2022
92f2ddb
fix: correct uid/gid non-root mapping
dtrudg Nov 21, 2022
f5e51c3
chore: Update deps for CI, packages, docs
dtrudg Nov 21, 2022
af57b65
e2e: use root and user OCI profiles in action tests
dtrudg Nov 21, 2022
4563242
pkg: Update / tidy rpm spec file
dtrudg Nov 28, 2022
b8d648d
Update INSTALL.md - fix typo from PR review.
dtrudg Nov 28, 2022
3e3e6fd
pkg: fix Ubuntu 18.04 deb build
dtrudg Nov 28, 2022
f4c677c
oci: move some code to launcher, use explicit config
dtrudg Nov 21, 2022
2cdf179
oci: Add --fakeroot support to --oci mode
dtrudg Nov 21, 2022
5f196e9
fix: use conf file value for oci tmpfs size
dtrudg Nov 29, 2022
8d8de03
feat: oci: support namespace flags
dtrudg Dec 1, 2022
de885a3
chore: refactor for easier testing
dtrudg Dec 1, 2022
14405c8
test: oci: Test_addNamespaces
dtrudg Dec 1, 2022
53ac7f8
e2e: minimal --oci namespace request tests
dtrudg Dec 1, 2022
f73e208
fix: Don't set Process.Terminal in oci launcher if no term
dtrudg Dec 1, 2022
930836b
chore: move BindPath code out of runtime package
dtrudg Dec 2, 2022
f2a4cf2
feat: oci: enable bind mounts via --bind, --mount
dtrudg Dec 2, 2022
4052b17
e2e: port relevant --bind/mount action tests for --oci
dtrudg Dec 2, 2022
a63047a
fix: oci: disallow relative bind destinations
dtrudg Dec 2, 2022
3578fe6
chore: fix stutter bind.Bindxxxx lint
dtrudg Dec 2, 2022
8cf8779
feat: oci: support --env option in --oci mode
dtrudg Dec 5, 2022
ed191d1
e2e: add --oci --env tests
dtrudg Dec 6, 2022
75ec7b4
feat: oci: add SINGULARITYENV_ handling for --oci mode
dtrudg Dec 6, 2022
1da3b41
e2e: add SINGULARITYENV_ tests for --oci mode
dtrudg Dec 6, 2022
1c527b4
feat: oci: enable --env-file in --oci mode
dtrudg Dec 6, 2022
31ea98e
e2e: add --env-file tests for --oci mode
dtrudg Dec 6, 2022
d896ab6
doc: Add CHANGELOG entry for `--oci`
dtrudg Dec 7, 2022
3ec4133
fix: oci: ensure user/group entries in container
dtrudg Dec 8, 2022
5f601bf
feat: oci: Support --rocm with --oci mode
dtrudg Dec 8, 2022
1c653b9
e2e: minimal --rocm --oci test
dtrudg Dec 8, 2022
33b061b
fix: rocm: update rocmliblist and fix e2e tests
dtrudg Dec 8, 2022
8313a4d
doc: --rocm --oci CHANGELOG entry
dtrudg Dec 9, 2022
17fcf13
oci: support legacy --nv bind mode
dtrudg Dec 20, 2022
cdcf38e
chore: refactor runtime spec handling out of bundle
dtrudg Dec 22, 2022
92beb96
oci: inspection of image user in bundle
dtrudg Dec 29, 2022
073da5d
feat: oci: honor USER in image config
dtrudg Dec 29, 2022
4a03673
fix: lack of passwd / group should be warning in --oci mode
dtrudg Feb 6, 2023
a489ef6
oci: pass in SystemContext for image handling
dtrudg Jan 6, 2023
0137ee3
oci: Allow disabled cache in oci launcher
dtrudg Jan 6, 2023
1b3230f
fix: e2e: docker rmi ref, not uri
dtrudg Jan 9, 2023
c7ec495
fix: change option for oci launcher unsupported option test
dtrudg Jan 9, 2023
fb2ec7d
feat: oci: support cgroups requests in --oci mode
dtrudg Dec 13, 2022
01c9820
fix: fall back to cgroupfs for OCI non-root, non cgroups v2
dtrudg Mar 6, 2023
d59ca94
oci: drop warning about runc functionality
dtrudg Mar 8, 2023
267615e
rpm: fix: correct BuildRequires/Requires for SLES
dtrudg Mar 17, 2023
3103743
e2e: refactor test image handling
dtrudg Feb 24, 2023
7117ded
oci: implemented CDI device mapping (sylabs/singularity#1459)
Mar 27, 2023
2b2572c
oci: support --hostname (sylabs/singularity#1495)
Mar 30, 2023
2b03310
oci: support --scratch (sylabs/singularity#1498)
Mar 31, 2023
c3f315d
oci: support --pwd (sylabs/singularity#1558)
Apr 13, 2023
f6c60a8
oci: support --home (sylabs/singularity#1500)
Apr 3, 2023
0e2dba6
oci: improvements to cdi support
Apr 3, 2023
de564cb
fix: oci: explicitly request userns for inner reverse idmap
dtrudg Apr 5, 2023
ff5bd89
fix: oci: reverse uid/gid maps now honour target IDs
dtrudg Apr 11, 2023
569b626
fix: oci: enter cgroup before executing crun as non-root
dtrudg Apr 11, 2023
3ee67e0
fix: TERM not set in OCI containers
Apr 12, 2023
27de69c
oci: support resolv.conf and --dns
Apr 12, 2023
9803987
warn instead of failing when container lacks /etc (cf. issue1286)
Apr 12, 2023
359200e
added rudimentary tests for --dns
Apr 12, 2023
6cc1809
fix: oci: honour config passwd / config group directives
dtrudg Apr 13, 2023
3527ad6
fix: oci: honour mount proc/sys/tmp/home directives
dtrudg Apr 13, 2023
d4220cd
fix: oci: honour config resolv_conf directive
dtrudg Apr 13, 2023
fc9ad81
fixed typo (resolve.conf -> resolv.conf) (sylabs/singularity#1566)
Apr 14, 2023
b71fc58
pull HashingListSubtract into (new) high-level util package (sylabs/s…
Apr 14, 2023
ad089bc
fix: oci: Don't create cgroup for crun on v1 / cgroupfs
dtrudg Apr 17, 2023
2decb88
fix: Remove files with restrictive perms from --oci temp rootfs
dtrudg Apr 21, 2023
d78657a
oci: Enable --writable-tmpfs behaviour by default
dtrudg May 2, 2023
aa691e5
1481 support pwd in oci mode (sylabs/singularity#1496)
Apr 3, 2023
712ed4c
oci: fix --cwd/--pwd and actionOciExec() e2e-test
Apr 5, 2023
58be7e5
oci: fix --home when running as root or fakeroot (sylabs/singularity#…
Apr 10, 2023
f033d46
oci: fix to not override HOME when container specifies USER (+ e2e te…
Apr 24, 2023
05a9efc
oci: support --overlay (sylabs/singularity#1659)
May 11, 2023
061b653
wrap in writabletmpfs overlay if there's only read-only overlay(s)
May 11, 2023
f96e620
improved unmounting of user-supplied overlays
May 12, 2023
002535d
added e2e testing for 1670 regression
May 12, 2023
3bcbf68
oci: add e2e OCIRoot test to check proper unmounting of overlays
May 12, 2023
c8508ef
chg --workdir usage msg: remove mention of $HOME
May 17, 2023
11992df
oci: support --workdir
May 17, 2023
166b35b
rel. path --workdir/--scratch fix; code style improvements
May 18, 2023
56364e4
fix: correct Stdin wire-up in runc/crun execs
dtrudg May 30, 2023
7e357b0
e2e: port action STDPIPE tests to --oci mode
dtrudg May 30, 2023
8691b8e
oci: support --overlay of bare images (sylabs/singularity#1699)
May 30, 2023
16972cb
move overlay test images to test/ subtree
May 30, 2023
ccdb465
Disable check_pkg_no_buildcfg temporarily
edytuk Jul 3, 2023
765cc92
fix rel. path --workdir with --scratch, add native and oci e2e tests
May 18, 2023
37e24e5
error out when workdir can't be converted to abs path
May 19, 2023
1516258
privileged cleanup in (oci)RelWorkdirScratch tests
May 19, 2023
d115f91
Merge pull request #334 from edytuk/sylabs1694v3
edytuk Jul 6, 2023
12fb599
oci: fallback to fuse-overlayfs if kernel doesn't support unprivilege…
Jun 6, 2023
c3fa965
oci: support for writable extfs img overlay via fuse-overlayfs
Jun 8, 2023
d4fdf44
do not re-use the rootfs name for overlay upper dir
DrDaveD Jul 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,12 @@ jobs:
go-version: 1.20.5

- name: Fetch deps
run: sudo apt-get -q update && sudo DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential squashfs-tools squashfuse fuse-overlayfs fakeroot fuse2fs libseccomp-dev cryptsetup dbus-user-session
run: sudo apt-get -q update && sudo DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential squashfs-tools squashfuse fuse-overlayfs fakeroot fuse2fs libseccomp-dev cryptsetup dbus-user-session conmon

- name: Install crun
run: |
sudo curl -L -o /usr/local/bin/crun https://github.com/containers/crun/releases/download/1.6/crun-1.6-linux-amd64
sudo chmod +x /usr/local/bin/crun

- name: Build and install Apptainer
run: |
Expand Down Expand Up @@ -268,7 +273,12 @@ jobs:
go-version: 1.20.5

- name: Fetch deps
run: sudo apt-get -q update && sudo DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential squashfs-tools libseccomp-dev cryptsetup dbus-user-session
run: sudo apt-get -q update && sudo DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential squashfs-tools libseccomp-dev cryptsetup dbus-user-session conmon

- name: Install crun
run: |
sudo curl -L -o /usr/local/bin/crun https://github.com/containers/crun/releases/download/1.6/crun-1.6-linux-amd64
sudo chmod +x /usr/local/bin/crun

- name: Build and install Apptainer
run: |
Expand Down Expand Up @@ -314,7 +324,12 @@ jobs:

- name: Fetch deps
if: env.run_tests
run: sudo apt-get -q update && sudo DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential uidmap squashfs-tools squashfuse fuse-overlayfs fakeroot fuse2fs libseccomp-dev cryptsetup dbus-user-session
run: sudo apt-get -q update && sudo DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential uidmap squashfs-tools squashfuse fuse-overlayfs fakeroot fuse2fs libseccomp-dev cryptsetup dbus-user-session conmon

- name: Install crun
run: |
sudo curl -L -o /usr/local/bin/crun https://github.com/containers/crun/releases/download/1.6/crun-1.6-linux-amd64
sudo chmod +x /usr/local/bin/crun

- name: Fetch gocryptfs
run: wget -O gocryptfs.tar.gz https://github.com/rfjakob/gocryptfs/releases/download/v2.3/gocryptfs_v2.3_linux-static_amd64.tar.gz && sudo tar xzvf gocryptfs.tar.gz -C /usr/local/bin gocryptfs
Expand Down Expand Up @@ -362,6 +377,7 @@ jobs:
retention-days: 7

check_pkg_no_buildcfg:
if: ${{ github.base_ref != 'oci-action' }}
name: check_pkg_no_buildcfg
runs-on: ubuntu-22.04
steps:
Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,12 @@ pkg/library/client/test[0-9]*
/debian

LICENSE_DEPENDENCIES.csv

# VSCode debugging build targets
__debug_bin
*/__debug_bin
*/*/__debug_bin
*/*/*/__debug_bin
*/*/*/*/__debug_bin
*/*/*/*/*/__debug_bin
*/*/*/*/*/*/__debug_bin
64 changes: 64 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,77 @@ For older changes see the [archived Singularity change log](https://github.com/a
working directory, though `--pwd` is still supported for compatibility.
- When building RPM, we will now use `/var/lib/apptainer` (rather than
`/var/apptainer`) to store local state files.
- The `apptainer oci` command group now uses `crun`, when available, or otherwise
`runc` to manage containers.
- The `apptainer oci` flags `--sync-socket`, `--empty-process`, and
`--timeout` have been removed.
- `sessiondir maxsize` in `apptainer.conf` now defaults to 64 MiB for new
installations. This is an increase from 16 MiB in prior versions.

### New Features & Functionality

- The `remote status` command will now print the username, realname, and email
of the logged-in user, if available.
- New option `--warn-unused-build-args` is provided to output warnings rather than
fatal errors for any unused variables given in --build-arg or --build-arg-file.
- A new `--oci` flag for `run/exec/shell` enables the experimental OCI runtime
mode. This mode:
- Runs OCI container images from an OCI bundle, using `runc` or `crun`.
- Supports `docker://`, `docker-archive:`, `docker-daemon:`, `oci:`,
`oci-archive:` image sources.
- Does not support running Apptainer SIF, SquashFS, or EXT3 images.
- Provides an environment similar to Apptainer's native runtime, running
with `--compat`.
- Supports the following options / flags. Other options are not yet supported:
- `--fakeroot` for effective root in the container. Requires subuid/subgid
mappings.
- Bind mounts via `--bind` or `--mount`. No image mounts.
- Additional namespaces requests with `--net`, `--uts`, `--user`.
- Container environment variables via `--env`, `--env-file`, and
`APPTAINERENV_` host env vars.
- `--rocm` to bind ROCm GPU libraries and devices into the container.
- `--nv` to bind Nvidia driver / basic CUDA libraries and devices into
the container.
- `--apply-cgroups`, and the `--cpu*`, `--blkio*`, `--memory*`,
`--pids-limit` flags to apply resource limits.
- Added `--device` flag to "action" commands (`run`/`exec`/`shell`) when run in
OCI mode (`--oci`). Currently supports passing one or more (comma-separated)
fully-qualified CDI device names, and those devices will then be made
available inside the container.
- Added `--cdi-dirs` flag to override the default search locations for CDI
json files, allowing, for example, users who don't have root access on their
host machine to nevertheless create CDI mappings (into containers run with
`--fakeroot`, for example).
- OCI mode now supports `--hostname` (requires UTS namespace, therefore this
flag will infer `--uts`).
- OCI mode now supports `--scratch` (shorthand: `-S`) to mount a tmpfs scratch
directory in the container.
- Support `--pwd` in OCI mode.
- OCI mode now supports `--home`. Supplying a single location (e.g.
`--home /myhomedir`) will result in a new tmpfs directory being created at the
specified location inside the container, and that dir being set as the
in-container user's home dir. Supplying two locations separated by a colon
(e.g. `--home /home/user:/myhomedir`) will result in the first location on the
host being bind-mounted as the second location in-container, and set as
the in-container user's home dir.
- OCI mode now handles `--dns` and `resolv.conf` on par with native mode: the
`--dns` flag can be used to pass a comma-separated list of DNS servers that
will be used in the container; if this flag is not used, the container will
use the same `resolv.conf` settings as the host.
- OCI-mode now supports the `--overlay <arg>` flag. `<arg>` can be the path to a
writable directory or writable extfs image, in which case changes to the
filesystem will persist across runs of the OCI container. Alternatively,
`--overlay <arg>:ro` can be used, where `<arg>` is the path to a directory, to
a squashfs image, or to an extfs image, to be mounted as a read-only overlay.
Multiple overlays can be specified, but all but one must be read-only.
- OCI-mode now supports the `--workdir <workdir>` option. If this option is
specified, `/tmp` and `/var/tmp` will be mapped, respectively, to
`<workdir>/tmp` and `<workdir>/var_tmp` on the host, rather than to tmpfs
storage. If `--scratch <scratchdir>` is used in conjunction with `--workdir`,
scratch directories will be mapped to subdirectories nested under
`<workdir>/scratch` on the host, rather than to tmpfs storage.
- If kernel does not support unprivileged overlays, OCI-mode will attempt to use
`fuse-overlayfs` and `fusermount` for overlay mounting and unmounting.

### New Features & Functionality

Expand Down
20 changes: 17 additions & 3 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,16 @@ sudo apt-get install -y \
fuse-overlayfs \
fakeroot \
cryptsetup \
curl wget git
curl wget git \
conmon crun
```

_Note_: on Ubuntu 18.04 or Debian 10 leave out `conmon`, `crun`, and
`fuse-overlayfs` because they are not available, or install them from another
source. Leaving out the first two will prevent the `--oci` option from working
and leaving out the third will prevent `--overlay` and `--writable-tmpfs`
options from working without suid mode.

On CentOS/RHEL:

```sh
Expand All @@ -47,9 +54,12 @@ sudo yum install -y \
fakeroot \
/usr/*bin/fuse2fs \
cryptsetup \
wget git
wget git \
conmon crun
```

_Note - use `runc` instead of `crun` on CentOS/RHEL 7._

On SLE/openSUSE

```sh
Expand All @@ -59,9 +69,13 @@ sudo zypper install -y \
libuuid-devel \
openssl-devel \
cryptsetup sysuser-tools \
gcc go
gcc go \
conmon crun
```

_Note - `crun` / `runc` can be omitted if you will not use the `apptainer oci`
commands, or the `--oci` execution mode._

## Install Go

Apptainer is written in Go, and may require a newer version of Go than is
Expand Down
52 changes: 50 additions & 2 deletions LICENSE_DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ The dependencies and their licenses are as follows:

**License URL:** <https://github.com/Netflix/go-expect/blob/master/LICENSE>

## github.com/container-orchestrated-devices/container-device-interface

**License:** Apache-2.0

**License URL:** <https://github.com/container-orchestrated-devices/container-device-interface/blob/master/LICENSE>

## github.com/containerd/containerd

**License:** Apache-2.0
Expand All @@ -35,6 +41,12 @@ The dependencies and their licenses are as follows:

**License URL:** <https://github.com/containernetworking/plugins/blob/master/LICENSE>

## github.com/containers/common

**License:** Apache-2.0

**License URL:** <https://github.com/containers/common/blob/master/LICENSE>

## github.com/containers/image/v5

**License:** Apache-2.0
Expand All @@ -53,11 +65,11 @@ The dependencies and their licenses are as follows:

**License URL:** <https://github.com/containers/ocicrypt/blob/master/LICENSE>

## github.com/containers/storage/pkg
## github.com/containers/storage

**License:** Apache-2.0

**License URL:** <https://github.com/containers/storage/blob/master/pkg/LICENSE>
**License URL:** <https://github.com/containers/storage/blob/master/LICENSE>

## github.com/coreos/go-iptables/iptables

Expand Down Expand Up @@ -287,6 +299,18 @@ The dependencies and their licenses are as follows:

**License URL:** <https://github.com/opencontainers/runtime-spec/blob/master/specs-go/LICENSE>

## github.com/opencontainers/runtime-tools

**License:** Apache-2.0

**License URL:** <https://github.com/opencontainers/runtime-tools/blob/master/LICENSE>

## github.com/opencontainers/selinux

**License:** Apache-2.0

**License URL:** <https://github.com/opencontainers/selinux/blob/master/LICENSE>

## github.com/opencontainers/umoci

**License:** Apache-2.0
Expand Down Expand Up @@ -521,6 +545,12 @@ The dependencies and their licenses are as follows:

**License URL:** <https://github.com/cyphar/filepath-securejoin/blob/master/LICENSE>

## github.com/fsnotify/fsnotify

**License:** BSD-3-Clause

**License URL:** <https://github.com/fsnotify/fsnotify/blob/master/LICENSE>

## github.com/gogo/protobuf/proto

**License:** BSD-3-Clause
Expand Down Expand Up @@ -623,6 +653,12 @@ The dependencies and their licenses are as follows:

**Project URL:** <https://golang.org/x/exp>

## golang.org/x/mod/semver

**License:** BSD-3-Clause

**Project URL:** <https://golang.org/x/mod/semver>

## golang.org/x/net

**License:** BSD-3-Clause
Expand Down Expand Up @@ -869,6 +905,12 @@ The dependencies and their licenses are as follows:

**License URL:** <https://github.com/rivo/uniseg/blob/master/LICENSE.txt>

## github.com/samber/lo

**License:** MIT

**License URL:** <https://github.com/samber/lo/blob/master/LICENSE>

## github.com/secure-systems-lab/go-securesystemslib/dsse

**License:** MIT
Expand Down Expand Up @@ -917,6 +959,12 @@ The dependencies and their licenses are as follows:

**Project URL:** <https://gopkg.in/yaml.v3>

## sigs.k8s.io/yaml

**License:** MIT

**Project URL:** <https://sigs.k8s.io/yaml>

## github.com/gosimple/slug

**License:** MPL-2.0
Expand Down
Loading