Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Fix privileged caps #518

Merged
merged 1 commit into from
Jan 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion pkg/server/container_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func (c *criContainerdService) generateContainerSpec(id string, sandboxPid uint3
if err != nil {
return nil, err
}
g := generate.NewFromSpec(spec)
g := newSpecGenerator(spec)

// Set the relative path to the rootfs of the container from containerd's
// pre-defined directory.
Expand Down
3 changes: 1 addition & 2 deletions pkg/server/container_execsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
containerdio "github.com/containerd/containerd/cio"
"github.com/containerd/containerd/errdefs"
"github.com/golang/glog"
"github.com/opencontainers/runtime-tools/generate"
"golang.org/x/net/context"
"golang.org/x/sys/unix"
"k8s.io/client-go/tools/remotecommand"
Expand Down Expand Up @@ -100,7 +99,7 @@ func (c *criContainerdService) execInContainer(ctx context.Context, id string, o
return nil, fmt.Errorf("failed to load task: %v", err)
}
if opts.tty {
g := generate.NewFromSpec(spec)
g := newSpecGenerator(spec)
g.AddProcessEnv("TERM", "xterm")
spec = g.Spec()
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/server/container_update_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/containerd/typeurl"
"github.com/golang/glog"
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-tools/generate"
"golang.org/x/net/context"
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"

Expand Down Expand Up @@ -133,7 +132,7 @@ func updateOCILinuxResource(spec *runtimespec.Spec, new *runtime.LinuxContainerR
if err := util.DeepCopy(&cloned, spec); err != nil {
return nil, fmt.Errorf("failed to deep copy: %v", err)
}
g := generate.NewFromSpec(&cloned)
g := newSpecGenerator(&cloned)

if new.GetCpuPeriod() != 0 {
g.SetLinuxResourcesCPUPeriod(uint64(new.GetCpuPeriod()))
Expand Down
9 changes: 9 additions & 0 deletions pkg/server/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ import (
imagedigest "github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/identity"
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-tools/generate"
"github.com/opencontainers/selinux/go-selinux"
"github.com/opencontainers/selinux/go-selinux/label"
"golang.org/x/net/context"
Expand Down Expand Up @@ -397,3 +399,10 @@ func buildLabels(configLabels map[string]string, containerType string) map[strin
labels[containerKindLabel] = containerType
return labels
}

// newSpecGenerator creates a new spec generator for the runtime spec.
func newSpecGenerator(spec *runtimespec.Spec) generate.Generator {
g := generate.NewFromSpec(spec)
g.HostSpecific = true
return g
}
3 changes: 1 addition & 2 deletions pkg/server/sandbox_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/golang/glog"
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-tools/generate"
"golang.org/x/net/context"
"golang.org/x/sys/unix"
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
Expand Down Expand Up @@ -240,7 +239,7 @@ func (c *criContainerdService) generateSandboxContainerSpec(id string, config *r
if err != nil {
return nil, err
}
g := generate.NewFromSpec(spec)
g := newSpecGenerator(spec)

// Apply default config from image config.
if err := addImageEnvs(&g, imageConfig.Env); err != nil {
Expand Down