Skip to content

Conversation

@kolyshkin
Copy link
Contributor

@kolyshkin kolyshkin commented Jan 5, 2022

This is another follow up to PRs #728 and #732, fixing a few issues introduced by them, with some related cleanups and fixes. Please see individual commits for more details.

In particular, this fixes rootfsPropagation test failure when running the test inside a Docker container), caused by 8e1a3b5 (which adds new capabilities to the list, and those caps are not yet known to Docker daemon used for CI).

Currently a draft which I am about to test in crun repo.

kolyshkin added a commit to kolyshkin/crun that referenced this pull request Jan 5, 2022
kolyshkin added a commit to kolyshkin/crun that referenced this pull request Jan 7, 2022
kolyshkin added a commit to kolyshkin/crun that referenced this pull request Jan 7, 2022
@kolyshkin kolyshkin changed the title Followup fixes to validator [DNM] Followup fixes to validator Jan 7, 2022
kolyshkin added a commit to kolyshkin/crun that referenced this pull request Jan 7, 2022
Commit fec9c3c added some logging to Clean.

First, it forgot to add newlines, resulting in some garbage in the
output. Fix by using fmt.Println.

Second, it logged error from Kill which is very frequent, since the
container might already be stopped. Fix by introducing and using
ForceDelete (aka delete --force).

Signed-off-by: Kir Kolyshkin <[email protected]>
It is always called with (true, true) so it doesn't make sense.

If a caller would want to keep a bundle dir, they should use r.Delete
or r.ForceDelete.

Signed-off-by: Kir Kolyshkin <[email protected]>
This test expects CAP_SYS_ADMIN to be set (in order to perform mounts).

Currently, if this capability is not set, it returns bare unix errno
(EPERM) from unix.Mount, which is very confusing, since the test just
prints "Operation not permitted" and exits.

Do the following changes:
 - move the first mount to before the switch, and skip the test when it
   returns EPERM;
 - wrap all unix.Mount errors to provide more context.

Signed-off-by: Kir Kolyshkin <[email protected]>
This code calls g.SetupPrivileged because validateRootfsPropagation
needs to perform mounts. In fact, setting CAP_SYS_ADMIN and removing
the generated seccomp profile (which does not enable mount/umount) is
sufficient.

Using the whole g.SetupPrivileged problematic when running tests
inside Docker running on a machine with new Linux kernels. The problem
is Docker does not (yet) know about recently added capabilities
(specifically, CAP_PERFMON, CAP_BPF, and CAP_CHECKPOINT_RESTORE,
brought in via commit 8e1a3b5), and thus runs a --privileged container
without those. This code, though, tries to set them all, relying on the
value of last capability to /proc/sys/kernel/cap_last_cap.  This results
in an error setting new capabilities, and thus the test errors out.

While at it, make the test name more descriptive, adding the propagation
that we're testing.

NOTE the same problem exists in validation/process_capabilities, and
needs to be addressed separately.

Fixes: 8e1a3b5
Signed-off-by: Kir Kolyshkin <[email protected]>
kolyshkin added a commit to kolyshkin/crun that referenced this pull request Jan 7, 2022
kolyshkin added a commit to kolyshkin/crun that referenced this pull request Jan 7, 2022
kolyshkin added a commit to kolyshkin/crun that referenced this pull request Jan 7, 2022
@kolyshkin
Copy link
Contributor Author

@kolyshkin kolyshkin marked this pull request as ready for review January 8, 2022 00:04
@kolyshkin kolyshkin changed the title [DNM] Followup fixes to validator Followup fixes to validator Jan 8, 2022
kolyshkin added a commit to kolyshkin/crun that referenced this pull request Jan 8, 2022
kolyshkin added a commit to kolyshkin/crun that referenced this pull request Jan 8, 2022
Copy link
Contributor

@mrunalp mrunalp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mrunalp mrunalp merged commit 7e2d60f into opencontainers:master Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants