Merge pull request #192 from fabiokung/cgroup-per-container
container id is the cgroup name
This commit is contained in:
commit
15c709ed73
|
@ -32,7 +32,7 @@ var restoreCommand = cli.Command{
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatal(err)
|
fatal(err)
|
||||||
}
|
}
|
||||||
config, err := createLibcontainerConfig(spec)
|
config, err := createLibcontainerConfig(context.GlobalString("id"), spec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatal(err)
|
fatal(err)
|
||||||
}
|
}
|
||||||
|
|
2
run.go
2
run.go
|
@ -26,7 +26,7 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func execContainer(context *cli.Context, spec *specs.LinuxSpec) (int, error) {
|
func execContainer(context *cli.Context, spec *specs.LinuxSpec) (int, error) {
|
||||||
config, err := createLibcontainerConfig(spec)
|
config, err := createLibcontainerConfig(context.GlobalString("id"), spec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return -1, err
|
return -1, err
|
||||||
}
|
}
|
||||||
|
|
8
spec.go
8
spec.go
|
@ -176,7 +176,7 @@ func checkSpecVersion(s *specs.LinuxSpec) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func createLibcontainerConfig(spec *specs.LinuxSpec) (*configs.Config, error) {
|
func createLibcontainerConfig(cgroupName string, spec *specs.LinuxSpec) (*configs.Config, error) {
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -215,7 +215,7 @@ func createLibcontainerConfig(spec *specs.LinuxSpec) (*configs.Config, error) {
|
||||||
if err := setupUserNamespace(spec, config); err != nil {
|
if err := setupUserNamespace(spec, config); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
c, err := createCgroupConfig(spec, config.Devices)
|
c, err := createCgroupConfig(cgroupName, spec, config.Devices)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -250,13 +250,13 @@ func createLibcontainerMount(cwd string, m specs.Mount) *configs.Mount {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createCgroupConfig(spec *specs.LinuxSpec, devices []*configs.Device) (*configs.Cgroup, error) {
|
func createCgroupConfig(name string, spec *specs.LinuxSpec, devices []*configs.Device) (*configs.Cgroup, error) {
|
||||||
myCgroupPath, err := cgroups.GetThisCgroupDir("devices")
|
myCgroupPath, err := cgroups.GetThisCgroupDir("devices")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
c := &configs.Cgroup{
|
c := &configs.Cgroup{
|
||||||
Name: getDefaultID(),
|
Name: name,
|
||||||
Parent: myCgroupPath,
|
Parent: myCgroupPath,
|
||||||
AllowedDevices: append(devices, allowedDevices...),
|
AllowedDevices: append(devices, allowedDevices...),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue