Skip to content

Commit 7a3c009

Browse files
authored
Merge pull request #175 from Snorch/memory-remove-wrong-kernel-limit-check
memory: remove wrong memory.kmem.limit_in_bytes check
2 parents 0ab9c40 + 4029019 commit 7a3c009

File tree

1 file changed

+0
-28
lines changed

1 file changed

+0
-28
lines changed

memory.go

-28
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"path/filepath"
2525
"strconv"
2626
"strings"
27-
"syscall"
2827

2928
v1 "github.com/containerd/cgroups/stats/v1"
3029
specs "github.com/opencontainers/runtime-spec/specs-go"
@@ -207,21 +206,6 @@ func (m *memoryController) Create(path string, resources *specs.LinuxResources)
207206
if resources.Memory == nil {
208207
return nil
209208
}
210-
if resources.Memory.Kernel != nil {
211-
// Check if kernel memory is enabled
212-
// We have to limit the kernel memory here as it won't be accounted at all
213-
// until a limit is set on the cgroup and limit cannot be set once the
214-
// cgroup has children, or if there are already tasks in the cgroup.
215-
for _, i := range []int64{1, -1} {
216-
if err := retryingWriteFile(
217-
filepath.Join(m.Path(path), "memory.kmem.limit_in_bytes"),
218-
[]byte(strconv.FormatInt(i, 10)),
219-
defaultFilePerm,
220-
); err != nil {
221-
return checkEBUSY(err)
222-
}
223-
}
224-
}
225209
return m.set(path, getMemorySettings(resources))
226210
}
227211

@@ -466,18 +450,6 @@ func getMemorySettings(resources *specs.LinuxResources) []memorySettings {
466450
}
467451
}
468452

469-
func checkEBUSY(err error) error {
470-
if pathErr, ok := err.(*os.PathError); ok {
471-
if errNo, ok := pathErr.Err.(syscall.Errno); ok {
472-
if errNo == unix.EBUSY {
473-
return fmt.Errorf(
474-
"failed to set memory.kmem.limit_in_bytes, because either tasks have already joined this cgroup or it has children")
475-
}
476-
}
477-
}
478-
return err
479-
}
480-
481453
func getOomControlValue(mem *specs.LinuxMemory) *int64 {
482454
if mem.DisableOOMKiller != nil && *mem.DisableOOMKiller {
483455
i := int64(1)

0 commit comments

Comments
 (0)