DjoDjo
(Johann)
September 24, 2017, 8:47am
1
Hello,
I tried the example from https://stgraber.org/2016/03/26/lxd-2-0-resource-control-412/ :
lxc config set vm550941 limits.cpu 2
lxc exec vm550941 – cat /proc/cpuinfo | grep ^proces
processor : 0
processor : 1
processor : 2
processor : 3
processor : 4
processor : 5
processor : 6
processor : 7
The config show that limit.cpu should be 2:
lxc config show vm550941
architecture: x86_64
config:
image.architecture: amd64
image.description: Debian stretch amd64 (20170923_22:42)
image.os: Debian
image.release: stretch
image.serial: “20170923_22:42”
limits.cpu: “2”
limits.memory: 1GB
limits.memory.swap: “false”
volatile.base_image: 53884ddced10c8dcd1ffbaaaeaa2997cdd6d02719e85558b70e4ae334576d27e
volatile.idmap.base: “0”
volatile.idmap.next: ‘[{“Isuid”:true,“Isgid”:true,“Hostid”:1000000,“Nsid”:0,“Maprange”:1000000000}]’
volatile.last_state.idmap: ‘[{“Isuid”:true,“Isgid”:true,“Hostid”:1000000,“Nsid”:0,“Maprange”:1000000000}]’
volatile.last_state.power: RUNNING
devices:
root:
path: /
pool: default
size: 10GB
type: disk
ephemeral: false
profiles:
default
stateful: false
description: “”
Same problem with memory limit.
Am I doing something wrong ?
lxd --version
2.17
uname -a
Linux test 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u5 (2017-09-19) x86_64 GNU/Linux
dpkg -l | grep lxc
ii liblxc1 1:2.0.7-2 amd64 Linux Containers userspace tools (library)
ii lxc 1:2.0.7-2 amd64 Linux Containers userspace tools
ii lxc-dev 1:2.0.7-2 amd64 Linux Containers userspace tools (development)
ii python3-lxc 1:2.0.7-2 amd64 Linux Containers userspace tools (Python 3.x bindings)
simos
(Simos Xenitellis)
September 24, 2017, 5:40pm
2
I just tried the same on Ubuntu 16.04 and it worked as expected. I set a limit for 1 CPU, and the container showed just one CPU in /proc/cpuinfo
I suppose that something might be missing from the Linux kernel of the Debian server.
Someone more knowledgeable might be able to shed some light.
DjoDjo
(Johann)
September 24, 2017, 7:10pm
3
Hello simos,
lxc-checkconfig
Kernel configuration not found at /proc/config.gz; searching…
Kernel configuration found at /boot/config-4.9.0-3-amd64
— Namespaces —
Namespaces: enabled
Utsname namespace: enabled
Ipc namespace: enabled
Pid namespace: enabled
User namespace: enabled
Network namespace: enabled
— Control groups —
Cgroup: enabled
Cgroup clone_children flag: enabled
Cgroup device: enabled
Cgroup sched: enabled
Cgroup cpu account: enabled
Cgroup memory controller: enabled
Cgroup cpuset: enabled
— Misc —
Veth pair device: enabled
Macvlan: enabled
Vlan: enabled
Bridges: enabled
Advanced netfilter: enabled
CONFIG_NF_NAT_IPV4: enabled
CONFIG_NF_NAT_IPV6: enabled
CONFIG_IP_NF_TARGET_MASQUERADE: enabled
CONFIG_IP6_NF_TARGET_MASQUERADE: enabled
CONFIG_NETFILTER_XT_TARGET_CHECKSUM: enabled
FUSE (for use with lxcfs): enabled
— Checkpoint/Restore —
checkpoint restore: enabled
CONFIG_FHANDLE: enabled
CONFIG_EVENTFD: enabled
CONFIG_EPOLL: enabled
CONFIG_UNIX_DIAG: enabled
CONFIG_INET_DIAG: enabled
CONFIG_PACKET_DIAG: enabled
CONFIG_NETLINK_DIAG: enabled
File capabilities: enabled
Note : Before booting a new kernel, you can check its configuration
usage : CONFIG=/path/to/config /usr/bin/lxc-checkconfig
The kernel config seems fine ?
stgraber
(Stéphane Graber)
September 25, 2017, 2:42pm
4
You’re missing lxcfs.
The limits will be applied by LXD, but you need lxcfs to setup the file overlay on /proc/cpuinfo and other similar files so that the limit can be seen from inside the container.
DjoDjo
(Johann)
September 26, 2017, 9:11pm
5
Yep this fixed the problem, thank you
zacksiri
(Zack Siri)
October 10, 2017, 10:38am
7
Sorry, I messed up, I had my lxc remote set to the wrong place.