Merge pull request #1350 from hqhq/fix_kmem_accouting
Fix kmem accouting when use with cgroupsPath
This commit is contained in:
commit
770e37fb32
|
@ -33,14 +33,18 @@ func (s *MemoryGroup) Apply(d *cgroupData) (err error) {
|
||||||
path, err := d.path("memory")
|
path, err := d.path("memory")
|
||||||
if err != nil && !cgroups.IsNotFound(err) {
|
if err != nil && !cgroups.IsNotFound(err) {
|
||||||
return err
|
return err
|
||||||
|
} else if path == "" {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
if memoryAssigned(d.config) {
|
if memoryAssigned(d.config) {
|
||||||
if path != "" {
|
if _, err := os.Stat(path); os.IsNotExist(err) {
|
||||||
if err := os.MkdirAll(path, 0755); err != nil {
|
if err := os.MkdirAll(path, 0755); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
// Only enable kernel memory accouting when this cgroup
|
||||||
if d.config.KernelMemory != 0 {
|
// is created by libcontainer, otherwise we might get
|
||||||
|
// error when people use `cgroupsPath` to join an existed
|
||||||
|
// cgroup whose kernel memory is not initialized.
|
||||||
if err := EnableKernelMemoryAccounting(path); err != nil {
|
if err := EnableKernelMemoryAccounting(path); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue