oci.WithPrivileged: set the current caps, not the known caps
This change is needed for running the latest containerd inside Docker that is not aware of the recently added caps (BPF, PERFMON, CHECKPOINT_RESTORE). Without this change, containerd inside Docker fails to run containers with "apply caps: operation not permitted" error. See kubernetes-sigs/kind 2058 NOTE: The caller process of this function is now assumed to be as privileged as possible. Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
|
||||
"github.com/containerd/containerd/containers"
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
"github.com/containerd/containerd/pkg/testutil"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
)
|
||||
|
||||
@@ -251,6 +252,10 @@ func TestPopulateDefaultUnixSpec(t *testing.T) {
|
||||
|
||||
func TestWithPrivileged(t *testing.T) {
|
||||
t.Parallel()
|
||||
if runtime.GOOS == "linux" {
|
||||
// because WithPrivileged depends on CapEff in /proc/self/status
|
||||
testutil.RequiresRoot(t)
|
||||
}
|
||||
|
||||
ctx := namespaces.WithNamespace(context.Background(), "testing")
|
||||
|
||||
@@ -272,6 +277,10 @@ func TestWithPrivileged(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if runtime.GOOS != "linux" {
|
||||
return
|
||||
}
|
||||
|
||||
if len(s.Process.Capabilities.Bounding) == 0 {
|
||||
t.Error("Expected capabilities to be set with privileged")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user