Adjust cgroup change in libcontainer

This commit is contained in:
Shengjing Zhu
2020-08-19 23:57:26 +08:00
parent 6a1139b9fe
commit 274bf2ee1c
4 changed files with 24 additions and 22 deletions

View File

@@ -9,11 +9,11 @@ import (
"github.com/containernetworking/plugins/pkg/ns"
multierror "github.com/hashicorp/go-multierror"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/plugins/drivers"
"github.com/opencontainers/runc/libcontainer/cgroups"
cgroupFs "github.com/opencontainers/runc/libcontainer/cgroups/fs"
lconfigs "github.com/opencontainers/runc/libcontainer/configs"
"github.com/opencontainers/runc/libcontainer/specconv"
)
// runAs takes a user id as a string and looks up the user, and sets the command
@@ -71,11 +71,12 @@ func (e *UniversalExecutor) runAs(userid string) error {
func (e *UniversalExecutor) configureResourceContainer(pid int) error {
cfg := &lconfigs.Config{
Cgroups: &lconfigs.Cgroup{
Resources: &lconfigs.Resources{
AllowAllDevices: helper.BoolToPtr(true),
},
Resources: &lconfigs.Resources{},
},
}
for _, device := range specconv.AllowedDevices {
cfg.Cgroups.Resources.Devices = append(cfg.Cgroups.Resources.Devices, &device.DeviceRule)
}
err := configureBasicCgroups(cfg)
if err != nil {