forked from apptainer/apptainer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As a first step toward run/shell/exec actions on native OCI images, implement a minimal `singularity run --oci mybundle` which: * Requires an on-disk bundle with appropriate `config.json`. * Runs this bundle using `crun` or `runc`. * Makes no attempt to handle any arguments or options. * Does not modify the `config.json` - i.e. it must match namespace / mapping requirements for rootless execution etc. At this stage, the functionality is essentially equivalent to `singularity oci run` and is not yet useful. The primary purpose of the PR is to refactor some of the code that passes args for launching a container. In addition, we now use `crun` in preference to `runc` if available. `crun` supports e.g. single uid->uid mapping in a usernamespace (without root mapping). Closes sylabs/singularity#598 Signed-off-by: Edita Kizinevic <[email protected]>
- Loading branch information
Showing
16 changed files
with
241 additions
and
116 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
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
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
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,82 @@ | ||
// Copyright (c) Contributors to the Apptainer project, established as | ||
// Apptainer a Series of LF Projects LLC. | ||
// For website terms of use, trademark policy, privacy policy and other | ||
// project policies see https://lfprojects.org/policies | ||
// Copyright (c) 2022, Sylabs Inc. All rights reserved. | ||
// This software is licensed under a 3-clause BSD license. Please consult the | ||
// LICENSE.md file distributed with the sources of this project regarding your | ||
// rights to use or distribute this software. | ||
|
||
package actions | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/apptainer/apptainer/e2e/internal/e2e" | ||
"github.com/apptainer/apptainer/internal/pkg/test/tool/require" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
func (c actionTests) ociBundle(t *testing.T) (string, func()) { | ||
require.Seccomp(t) | ||
require.Filesystem(t, "overlay") | ||
|
||
bundleDir, err := os.MkdirTemp(c.env.TestDir, "bundle-") | ||
if err != nil { | ||
err = errors.Wrapf(err, "creating temporary bundle directory at %q", c.env.TestDir) | ||
t.Fatalf("failed to create bundle directory: %+v", err) | ||
} | ||
c.env.RunApptainer( | ||
t, | ||
e2e.WithProfile(e2e.RootProfile), | ||
e2e.WithCommand("oci mount"), | ||
e2e.WithArgs(c.env.ImagePath, bundleDir), | ||
e2e.ExpectExit(0), | ||
) | ||
|
||
cleanup := func() { | ||
c.env.RunApptainer( | ||
t, | ||
e2e.WithProfile(e2e.RootProfile), | ||
e2e.WithCommand("oci umount"), | ||
e2e.WithArgs(bundleDir), | ||
e2e.ExpectExit(0), | ||
) | ||
os.RemoveAll(bundleDir) | ||
} | ||
|
||
return bundleDir, cleanup | ||
} | ||
|
||
func (c actionTests) actionOciRun(t *testing.T) { | ||
e2e.EnsureImage(t, c.env) | ||
|
||
bundle, cleanup := c.ociBundle(t) | ||
defer cleanup() | ||
|
||
tests := []struct { | ||
name string | ||
argv []string | ||
exit int | ||
}{ | ||
{ | ||
name: "NoCommand", | ||
argv: []string{bundle}, | ||
exit: 0, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
c.env.RunApptainer( | ||
t, | ||
e2e.AsSubtest(tt.name), | ||
e2e.WithProfile(e2e.OCIRootProfile), | ||
e2e.WithCommand("run"), | ||
// While we don't support args we are entering a /bin/sh interactively, so we need to exit. | ||
e2e.ConsoleRun(e2e.ConsoleSendLine("exit")), | ||
e2e.WithArgs(tt.argv...), | ||
e2e.ExpectExit(tt.exit), | ||
) | ||
} | ||
} |
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
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
Oops, something went wrong.