Merge pull request #1350 from hqhq/fix_kmem_accouting

Fix kmem accouting when use with cgroupsPath
This commit is contained in:
Daniel, Dao Quang Minh 2017-02-27 15:25:41 +00:00 committed by GitHub
commit 770e37fb32
1 changed files with 7 additions and 3 deletions

View File

@ -33,14 +33,18 @@ func (s *MemoryGroup) Apply(d *cgroupData) (err error) {
path, err := d.path("memory")
if err != nil && !cgroups.IsNotFound(err) {
return err
} else if path == "" {
return nil
}
if memoryAssigned(d.config) {
if path != "" {
if _, err := os.Stat(path); os.IsNotExist(err) {
if err := os.MkdirAll(path, 0755); err != nil {
return err
}
}
if d.config.KernelMemory != 0 {
// Only enable kernel memory accouting when this cgroup
// 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 {
return err
}