-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory swap fix for non supporting kernels #249
Conversation
@LK4D4 @crosbymichael @mrunalp |
if cgroup.MemorySwap > 0 { | ||
if err := writeFile(path, "memory.memsw.limit_in_bytes", strconv.FormatInt(cgroup.MemorySwap, 10)); err != nil { | ||
return err | ||
if _, err := os.Stat(filepath.Join(path, "memory.memsw.limit_in_bytes")); err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe move this after if cgroup.MemorySwap > 0 {
check
This is a wider problem than just memory swap, we used to depend on Docker to check if these configs are valid (related kernel configs are enabled or such files are existed), now runC are used without Docker, we probably need something like https://github.com/docker/docker/blob/master/daemon/daemon.go#L1083 in runC. |
f3913cf
to
7a9cacf
Compare
Something like pkg/sysinfo in docker https://github.com/docker/docker/blob/master/pkg/sysinfo/sysinfo_linux.go is needed to properly check if/which cgroups are enabled before writing to subsystem's files |
@runcom |
@rajasec yes I see, I'm just wondering if cgroups subsystem existence check should be made in libcontainer as you're doing here (I also think apply_systemd should be modified as well in this case) or it should be handled by runc as docker is doing |
@runcom |
7a9cacf
to
ff12092
Compare
@runcom @hqhq @LK4D4 @crosbymichael @mrunalp |
case "memory": | ||
if cgroup.MemorySwap > 0 { | ||
if !PathExists(filepath.Join(path, "memory.memsw.limit_in_bytes")) { | ||
logrus.Warn("Your kernel does not support swap memory limit.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about,
logrus.Warn("Your kernel does not support swap memory limit. Limitation discarded.")
Same as others.
Signed-off-by: Rajasekaran <rajasec79@gmail.com> Moved the stat check Signed-off-by: Rajasekaran <rajasec79@gmail.com> Added generic function for memory and cpu Signed-off-by: Rajasekaran <rajasec79@gmail.com> Modified the warning messages Signed-off-by: Rajasekaran <rajasec79@gmail.com>
ff12092
to
f820822
Compare
@hqhq |
I'm not fond of logrus calls in libcontainer :/ what about checking and adjusting Config in start.go (maybe) in runc before launching the container? Just thinking |
@runcom |
@crosbymichael @runcom @LK4D4 @mrunalp First option: Second option Your thoughts, whether existence of cgroup file in /sys/fs/cgroup/memory suffice enough to correct the config file as per option 2 |
Closing this to keep the discussion going in #262 |
ROADMAP.md: remove the tail spaces
@LK4D4 @crosbymichael @mrunalp
While I was modifying the swap value in config.json under memory section, it failed to write the value as the current kernel ( 3.19 : Ubuntu 15.04) and failed to start the container. Post that I have to update the grub to include cgroup_enable=memory swapaccount=1 which had "memory.memsw" values. So for the kernel which is not having "memory.memsw" by default, I have added the condition to check whether memory.memsw.limit_in_bytes is available before writing to the cgroup file.
Signed-off-by: Rajasekaran rajasec79@gmail.com