How to show low level cgroup config settings of a LXD container

(Daniel Clavijo Coca) #1

Hello, since LXD uses LXC under the hood, the resource limits applied to a LXD container via the limits.x keys must be mapped somehow to the cgroups configuration that LXC requires in order to limit resource. Is there a way to see the translation of a the high-level LXD limit settings to the cgroups?

I’m asking because, for example, to give a container, lets say any 2 CPUs of the host and a portion of those CPUs, I would, in LXD, issue:

lxc config set container limits.cpu 2
lxc config set container limits.cpu.allowance 50%

On LXC how could I achieve the same, if possible, using the raw cgroups configuration, or something else?

(Stéphane Graber) #2

/var/log/lxd/container/lxc.conf should contain the LXC config for this, if not, restarting the container should update it.

Alternatively you can directly go see what the values are in /sys/fs/cgroup

(Daniel Clavijo Coca) #3

Thanks, I checked that file and I don’t realize where is the CPU assignment. Let me explain myself.

I understand you can assign “any core” to a LXD container in a way that you don’t pin them, like having dynamic core assignment., with LXC I’ve read some cgroup doc and it seems you have to pin CPU. Can you “load balance” CPU assignment with LXC? Can you clarify this or am I missing something?

(Stéphane Graber) #4

Ah right, no you can’t do that part with pure LXC as LXC doesn’t have a central daemon that knows of all containers and can re-balance things as needed.

LXD does and is always running a background task which will re-balance all containers whenever a container is started or stopped or if a new CPU is added to the system. The result of that background task is an updated cpuset for every container.

(Daniel Clavijo Coca) #5

Wow, thanks for the clarification, I think it’s the first thread with this info. LXD is awesome !!!