Failed to set cgroup memory.limit

Does anyone know why this problem might be happening?

debian@br-lxd:~$ lxc config set fg-zulip limits.memory 2048MB
Error: Failed to set cgroup memory.limit_in_bytes="2048000000": setting cgroup item for the container failed

What happens if you directly attempt to write 2048000000 to /sys/fs/cgroup/memory/lxc.payload/fg-zulip/memory.usage_in_bytes?

How do I do that? sudo cat 2048000000 > /sys/fs etc.? Sorry, I’m having a slow day!

sudo -s
    echo 2048000000 > /sys/fs/cgroup/memory/lxc.payload/fg-zulip/memory.usage_in_bytes

Running sudo echo in one shot will not work as the write would still happen as your own user and so fail with a permission error.

Hmmm… no joy here either? lxc from snap is 3.18

debian@br-lxd:~$ sudo -s
[sudo] password for debian: 
root@br-lxd:/home/debian# echo 2048000000 > /sys/fs/cgroup/memory/lxc.payload/fg-zulip/memory.usage_in_bytes
bash: echo: write error: Invalid argument

I think it should be limit_in_bytes. Try doing echo 2048000000 > /sys/fs/cgroup/memory/lxc.payload/fg-zulip/memory.limit_in_bytes

Ok, interesting… When the container was running, I got this error

root@br-lxd:/home/debian# echo 2048000000 > /sys/fs/cgroup/memory/lxc.payload/fg-zulip/memory.limit_in_bytes                          
bash: echo: write error: Device or resource busy

When I stopped the container, I got this one…

root@br-lxd:/home/debian# echo 2048000000 > /sys/fs/cgroup/memory/lxc.payload/fg-zulip/memory.limit_in_bytes
bash: /sys/fs/cgroup/memory/lxc.payload/fg-zulip/memory.limit_in_bytes: No such file or directory

If you boot the container again can you try cat /sys/fs/cgroup/memory/lxc.payload/fg-zulip/memory.memsw.limit_in_bytes?

That makes sense, the cgroups probably get removed when you shut down the container.

No such file or directory

debian@br-lxd:~$ cat /sys/fs/cgroup/memory/lxc.payload/fg-zulip/memory.memsw.limit_in_bytes                                           
cat: /sys/fs/cgroup/memory/lxc.payload/fg-zulip/memory.memsw.limit_in_bytes: No such file or directory   

Is there a limit set in one of the parents that is smaller then what you are setting on this one?

Try cat /sys/fs/cgroup/memory/memory.limit_in_bytes for instance.

That returns 9223372036854771712 so I’m guessing that this doesn’t help?

Nope, that’s good. Not sure what it can be then :frowning:

Do you know what the command is to view existing limits on the container? Maybe that will help get a handle on things?

You can use lxc config show CONTAINERNAME --expanded and check the limits that it tries to apply there.