Skip to content
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

kmem.limit error when trying to run container #1083

Closed
crosbymichael opened this issue Sep 27, 2016 · 6 comments
Closed

kmem.limit error when trying to run container #1083

crosbymichael opened this issue Sep 27, 2016 · 6 comments
Labels

Comments

@crosbymichael
Copy link
Member

container_linux.go:247: starting container process caused "process_linux.go:258: applying cgroup configuration for process caused \"failed to set memory.kmem.limit_in_bytes, because either tasks have already joined this cgroup or it has children\""

I don't have a kmem.limit set in my config

@hqhq
Copy link
Contributor

hqhq commented Sep 28, 2016

Can't reproduce, is it on the latest runc? Any specific options or usage that can reproduce this?

@heartlock
Copy link

can you show me your config file? I can't reproduce

@crosbymichael
Copy link
Member Author

I don't think its config related. It happens after I start a container sometimes and try to restart it. I do have a couple paths nested as the cgroupsPath so it should be the correct error message about children processes but the handling for the feature is just bad right now.

{
   "platform" : {
      "arch" : "amd64",
      "os" : "linux"
   },
   "hostname" : "redis-master",
   "ociVersion" : "1.0.0-rc2-dev",
   "mounts" : [
      {
         "source" : "proc",
         "destination" : "/proc",
         "type" : "proc"
      },
      {
         "options" : [
            "nosuid",
            "strictatime",
            "mode=755",
            "size=65536k"
         ],
         "type" : "tmpfs",
         "source" : "tmpfs",
         "destination" : "/dev"
      },
      {
         "type" : "devpts",
         "options" : [
            "nosuid",
            "noexec",
            "newinstance",
            "ptmxmode=0666",
            "mode=0620",
            "gid=5"
         ],
         "destination" : "/dev/pts",
         "source" : "devpts"
      },
      {
         "destination" : "/dev/shm",
         "source" : "shm",
         "type" : "tmpfs",
         "options" : [
            "nosuid",
            "noexec",
            "nodev",
            "mode=1777",
            "size=65536k"
         ]
      },
      {
         "type" : "mqueue",
         "options" : [
            "nosuid",
            "noexec",
            "nodev"
         ],
         "destination" : "/dev/mqueue",
         "source" : "mqueue"
      },
      {
         "source" : "sysfs",
         "destination" : "/sys",
         "options" : [
            "nosuid",
            "noexec",
            "nodev"
         ],
         "type" : "sysfs"
      },
      {
         "type" : "tmpfs",
         "options" : [
            "nosuid",
            "strictatime",
            "mode=755",
            "size=65536k"
         ],
         "destination" : "/run",
         "source" : "tmpfs"
      },
      {
         "source" : "/etc/resolv.conf",
         "destination" : "/etc/resolv.conf",
         "options" : [
            "rbind",
            "ro"
         ],
         "type" : "bind"
      },
      {
         "type" : "bind",
         "options" : [
            "rbind",
            "ro"
         ],
         "destination" : "/etc/hosts",
         "source" : "/etc/hosts"
      },
      {
         "type" : "bind",
         "options" : [
            "rbind",
            "ro"
         ],
         "destination" : "/etc/localtime",
         "source" : "/etc/localtime"
      }
   ],
   "linux" : {
      "resources" : {
         "devices" : [
            {
               "allow" : false,
               "access" : "rwm"
            }
         ],
         "cpu" : {
            "period" : 100000,
            "quota" : 100000
         },
         "memory" : {
            "limit" : 134217728
         },
         "oomScoreAdj" : 0,
         "blockIO" : {}
      },
      "cgroupsPath" : "/containers/crosbymichael/redis-master",
      "namespaces" : [
         {
            "type" : "pid"
         },
         {
            "type" : "ipc"
         },
         {
            "type" : "uts"
         },
         {
            "type" : "mount"
         }
      ]
   },
   "hooks" : {},
   "process" : {
      "rlimits" : [
         {
            "soft" : 1024,
            "hard" : 1024,
            "type" : "RLIMIT_NOFILE"
         }
      ],
      "consoleSize" : {
         "height" : 0,
         "width" : 0
      },
      "noNewPrivileges" : true,
      "cwd" : "/",
      "env" : [
         "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
      ],
      "capabilities" : [
         "CAP_AUDIT_WRITE",
         "CAP_KILL",
         "CAP_FOWNER",
         "CAP_CHOWN",
         "CAP_MKNOD",
         "CAP_FSETID",
         "CAP_DAC_OVERRIDE",
         "CAP_SETFCAP",
         "CAP_SETPCAP",
         "CAP_SETGID",
         "CAP_SETUID",
         "CAP_NET_BIND_SERVICE"
      ],
      "user" : {
         "uid" : 0,
         "gid" : 0
      },
      "args" : [
         "/run/init"
      ]
   },
   "root" : {
      "path" : "rootfs"
   }
}

crosbymichael added a commit to crosbymichael/runc that referenced this issue Oct 7, 2016
Don't enable the kmem limit if it is not specified in the config.

Fixes opencontainers#1083

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
@hqhq hqhq closed this as completed in #1095 Oct 7, 2016
@cyphar
Copy link
Member

cyphar commented Oct 9, 2016

While #1095 solves the symptom, I don't think it actually solves the cause of the issue. @crosbymichael if you try to run your container again, but this time you do set a kmemcg limit will you get the same error (this is in the fairly dodgy kmem path, so I have no doubt there's a legitimate bug there somewhere)?

@asymfermion
Copy link

@crosbymichael I found that you have solved the problem and my code is also the latest, but the problem occur again and I do not know why. Could you please give me some advise?

@cyphar
Copy link
Member

cyphar commented Nov 11, 2016

@mangoZJ Please open a new issue with all of the relevant information.

hqhq added a commit to hqhq/runc that referenced this issue Feb 25, 2017
Fixes: opencontainers#1347
Fixes: opencontainers#1083

The root cause of opencontainers#1083 is because we're joining an
existed cgroup whose kmem accouting is not initialized,
and it has child cgroup or tasks in it.

Fix it by checking if the cgroup is first time created,
and we should enable kmem accouting if the cgroup is
craeted by libcontainer with or without kmem limit
configed. Otherwise we'll get issue like opencontainers#1347

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants