Closed alex14641 closed 3 months ago
Some Linux distributions have been switching away from using /proc/meminfo to instead using the sysinfo system call to get the memory usage.
This doesn't mean the limit isn't effective, it just means some tools won't report it.
You can set security.syscalls.intercept.sysinfo=true on the container to have Incus set up system call interception for sysinfo.
That did not work:
incus config set limited security.syscalls.intercept.sysinfo=true -p
incus stop --all
incus start limited
incus exec limited -- free -h
total used free shared buff/cache available
Mem: 31Gi 3.1Gi 14Gi 14Mi 14Gi 27Gi
Swap: 33Gi 0.0Ki 33Gi
incus config show limited
architecture: x86_64
config:
image.architecture: amd64
image.description: Ubuntu jammy amd64 (20240730_07:42)
image.os: Ubuntu
image.release: jammy
image.serial: "20240730_07:42"
image.type: squashfs
image.variant: default
limits.cpu: "1"
limits.memory: 128MiB
security.syscalls.intercept.sysinfo: "true"
volatile.base_image: 8d2363d8bffb11d95f1c766879e283fe50f94d47a2834dbc725133d5c1817442
volatile.cloud-init.instance-id: ff74ee32-aa78-4ade-b7ad-95c17221931a
volatile.eth0.host_name: vethad8735fe
volatile.eth0.hwaddr: 00:16:3e:6a:db:a5
volatile.idmap.base: "0"
volatile.idmap.current: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
volatile.idmap.next: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
volatile.last_state.idmap: '[]'
volatile.last_state.power: RUNNING
volatile.last_state.ready: "false"
volatile.uuid: b739c273-3e9e-49ee-a8ca-66d9028313d7
volatile.uuid.generation: b739c273-3e9e-49ee-a8ca-66d9028313d7
devices: {}
ephemeral: false
profiles:
Required information
Issue description
When creating an instance with memory limits, the limit is ignored.
Steps to reproduce
$ incus launch images:ubuntu/22.04 limited --config limits.cpu=1 --config limits.memory=192MiB
$ incus exec limited -- free -h
total used free shared buff/cache available
Mem: 31Gi 2.1Gi 24Gi 9.0Mi 5.1Gi 28Gi
Swap: 33Gi 0B 33Gi
What I expect to see: the limited memory of the container.
What I actually see: the memory of the host.
Information to attach
dmesg
)incus info NAME --show-log
) Name: limited Status: RUNNING Type: container Architecture: x86_64 PID: 4518 Created: 2024/07/30 19:32 EDT Last Used: 2024/07/30 19:32 EDT Started: 2024/07/30 19:32 EDTResources: Processes: 13 Disk usage: root: 567.05MiB CPU usage: CPU usage (in seconds): 1 Memory usage: Memory (current): 85.67MiB Network usage: eth0: Type: broadcast State: UP Host interface: vetha7a061dd MAC address: 00:16:3e:6d:3c:f2 MTU: 1500 Bytes received: 5.88kB Bytes sent: 4.00kB Packets received: 50 Packets sent: 39 IP addresses: inet: 10.107.140.157/24 (global) inet6: fd42:b300:757d:5791:216:3eff:fe6d:3cf2/64 (global) inet6: fe80::216:3eff:fe6d:3cf2/64 (link) lo: Type: loopback State: UP MTU: 65536 Bytes received: 0B Bytes sent: 0B Packets received: 0 Packets sent: 0 IP addresses: inet: 127.0.0.1/8 (local) inet6: ::1/128 (local)
Log:
lxc limited 20240730233249.639 WARN attach - ../src/lxc/attach.c:get_attach_context:478 - No security context received lxc limited 20240730233438.607 WARN attach - ../src/lxc/attach.c:get_attach_context:478 - No security context received lxc limited 20240730235001.559 WARN attach - ../src/lxc/attach.c:get_attach_context:478 - No security context received
incus config show NAME --expanded
)incus monitor --pretty
while reproducing the issue) DEBUG [2024-07-30T20:08:33-04:00] Event listener server handler started id=4addf771-4a07-4ac9-adf9-e2679e007a67 local=/spare/incus-6.0/data/unix.socket remote=@ DEBUG [2024-07-30T20:08:51-04:00] Handling API request ip=@ method=GET protocol=unix url=/1.0 username=adavis DEBUG [2024-07-30T20:08:51-04:00] Handling API request ip=@ method=GET protocol=unix url=/1.0/events username=adavis DEBUG [2024-07-30T20:08:51-04:00] Event listener server handler started id=5c0baeee-2c56-4017-b6fb-652be02c1811 local=/spare/incus-6.0/data/unix.socket remote=@ DEBUG [2024-07-30T20:08:51-04:00] Handling API request ip=@ method=POST protocol=unix url=/1.0/instances username=adavis DEBUG [2024-07-30T20:08:51-04:00] Responding to instance createDEBUG [2024-07-30T20:08:51-04:00] New operation class=task description="Creating instance" operation=15f2c701-9f3e-4adb-b9f8-06363f47be2e project=default DEBUG [2024-07-30T20:08:51-04:00] Started operation class=task description="Creating instance" operation=15f2c701-9f3e-4adb-b9f8-06363f47be2e project=default INFO [2024-07-30T20:08:51-04:00] ID: 15f2c701-9f3e-4adb-b9f8-06363f47be2e, Class: task, Description: Creating instance CreatedAt="2024-07-30 20:08:51.781378161 -0400 EDT" Err= Location=none MayCancel=false Metadata="map[]" Resources="map[instances:[/1.0/instances/limited]]" Status=Running StatusCode=Running UpdatedAt="2024-07-30 20:08:51.781378161 -0400 EDT" INFO [2024-07-30T20:08:51-04:00] ID: 15f2c701-9f3e-4adb-b9f8-06363f47be2e, Class: task, Description: Creating instance CreatedAt="2024-07-30 20:08:51.781378161 -0400 EDT" Err= Location=none MayCancel=false Metadata="map[]" Resources="map[instances:[/1.0/instances/limited]]" Status=Pending StatusCode=Pending UpdatedAt="2024-07-30 20:08:51.781378161 -0400 EDT" DEBUG [2024-07-30T20:08:51-04:00] Connecting to a remote simplestreams server URL="https://images.linuxcontainers.org" DEBUG [2024-07-30T20:08:51-04:00] Handling API request ip=@ method=GET protocol=unix url=/1.0/operations/15f2c701-9f3e-4adb-b9f8-06363f47be2e username=adavis DEBUG [2024-07-30T20:08:51-04:00] Lock acquired for image fingerprint=8d2363d8bffb11d95f1c766879e283fe50f94d47a2834dbc725133d5c1817442 DEBUG [2024-07-30T20:08:51-04:00] Acquiring lock for image fingerprint=8d2363d8bffb11d95f1c766879e283fe50f94d47a2834dbc725133d5c1817442 DEBUG [2024-07-30T20:08:51-04:00] Image already exists in the DB fingerprint=8d2363d8bffb11d95f1c766879e283fe50f94d47a2834dbc725133d5c1817442 DEBUG [2024-07-30T20:08:51-04:00] Instance operation lock created action=create instance=limited project=default reusable=false INFO [2024-07-30T20:08:51-04:00] Creating instance ephemeral=false instance=limited instanceType=container project=default DEBUG [2024-07-30T20:08:51-04:00] Adding device device=eth0 instance=limited instanceType=container project=default type=nic INFO [2024-07-30T20:08:51-04:00] Created instance ephemeral=false instance=limited instanceType=container project=default DEBUG [2024-07-30T20:08:51-04:00] Adding device device=root instance=limited instanceType=container project=default type=disk INFO [2024-07-30T20:08:51-04:00] Action: instance-created, Source: /1.0/instances/limited location=none storage-pool=incus6.0 type=container DEBUG [2024-07-30T20:08:51-04:00] CreateInstanceFromImage started driver=lvm instance=limited pool=incus6.0 project=default DEBUG [2024-07-30T20:08:51-04:00] EnsureImage started driver=lvm fingerprint=8d2363d8bffb11d95f1c766879e283fe50f94d47a2834dbc725133d5c1817442 pool=incus6.0 DEBUG [2024-07-30T20:08:51-04:00] Setting image volume size driver=lvm fingerprint=8d2363d8bffb11d95f1c766879e283fe50f94d47a2834dbc725133d5c1817442 pool=incus6.0 size=10GiB DEBUG [2024-07-30T20:08:51-04:00] Checking image volume size driver=lvm fingerprint=8d2363d8bffb11d95f1c766879e283fe50f94d47a2834dbc725133d5c1817442 pool=incus6.0 DEBUG [2024-07-30T20:08:52-04:00] EnsureImage finished driver=lvm fingerprint=8d2363d8bffb11d95f1c766879e283fe50f94d47a2834dbc725133d5c1817442 pool=incus6.0 DEBUG [2024-07-30T20:08:52-04:00] Set new volume size driver=lvm instance=limited pool=incus6.0 project=default size=10GiB DEBUG [2024-07-30T20:08:52-04:00] Checking volume size driver=lvm instance=limited pool=incus6.0 project=default DEBUG [2024-07-30T20:08:52-04:00] Logical volume snapshot created driver=lvm lv_name=containers_limited pool=incus6.0 src_dev=/dev/incus6.0/images_8d2363d8bffb11d95f1c766879e283fe50f94d47a2834dbc725133d5c1817442 thin=true vg_name=incus6.0 DEBUG [2024-07-30T20:08:52-04:00] Activated logical volume dev=/dev/incus6.0/containers_limited driver=lvm pool=incus6.0 volName=limited DEBUG [2024-07-30T20:08:52-04:00] Mounted logical volume dev=/dev/incus6.0/containers_limited driver=lvm options=discard path=/spare/incus-6.0/data/storage-pools/incus6.0/containers/limited pool=incus6.0 volName=limited DEBUG [2024-07-30T20:08:52-04:00] Unmounted logical volume driver=lvm keepBlockDev=false path=/spare/incus-6.0/data/storage-pools/incus6.0/containers/limited pool=incus6.0 volName=limited DEBUG [2024-07-30T20:08:52-04:00] Deactivated logical volume dev=/dev/incus6.0/containers_limited driver=lvm pool=incus6.0 volName=limited DEBUG [2024-07-30T20:08:52-04:00] CreateInstanceFromImage finished driver=lvm instance=limited pool=incus6.0 project=default DEBUG [2024-07-30T20:08:52-04:00] UpdateInstanceBackupFile started driver=lvm instance=limited pool=incus6.0 project=default DEBUG [2024-07-30T20:08:52-04:00] Activated logical volume dev=/dev/incus6.0/containers_limited driver=lvm pool=incus6.0 volName=limited DEBUG [2024-07-30T20:08:52-04:00] Mounted logical volume dev=/dev/incus6.0/containers_limited driver=lvm options=discard path=/spare/incus-6.0/data/storage-pools/incus6.0/containers/limited pool=incus6.0 volName=limited DEBUG [2024-07-30T20:08:52-04:00] Unmounted logical volume driver=lvm keepBlockDev=false path=/spare/incus-6.0/data/storage-pools/incus6.0/containers/limited pool=incus6.0 volName=limited DEBUG [2024-07-30T20:08:53-04:00] Instance operation lock finished action=create err="
DEBUG [2024-07-30T20:10:51-04:00] Handling API request ip=@ method=GET protocol=unix url=/1.0 username=adavis DEBUG [2024-07-30T20:10:51-04:00] Handling API request ip=@ method=GET protocol=unix url=/1.0/events username=adavis DEBUG [2024-07-30T20:10:51-04:00] Event listener server handler started id=be90c4cf-6bf6-4d89-ae93-9285b88ec3d5 local=/spare/incus-6.0/data/unix.socket remote=@ DEBUG [2024-07-30T20:10:51-04:00] Handling API request ip=@ method=POST protocol=unix url=/1.0/instances/limited/exec username=adavis DEBUG [2024-07-30T20:10:51-04:00] Started operation class=websocket description="Executing command" operation=9973b89c-eb37-47f2-a366-6107b1155dda project=default DEBUG [2024-07-30T20:10:51-04:00] New operation class=websocket description="Executing command" operation=9973b89c-eb37-47f2-a366-6107b1155dda project=default INFO [2024-07-30T20:10:51-04:00] ID: 9973b89c-eb37-47f2-a366-6107b1155dda, Class: websocket, Description: Executing command CreatedAt="2024-07-30 20:10:51.264352731 -0400 EDT" Err= Location=none MayCancel=false Metadata="map[command:[free -h] environment:map[HOME:/root LANG:C.UTF-8 PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin TERM:xterm-256color USER:root] fds:map[0:a72a1819ae4b994178c9996cea67caa925c5bb3ea3515defc796825cda0cd329 control:13992b728b32f8d7601c1c9d8579811d3c337482e408c87592e9f1dfd0cc45f2] interactive:true]" Resources="map[instances:[/1.0/instances/limited]]" Status=Pending StatusCode=Pending UpdatedAt="2024-07-30 20:10:51.264352731 -0400 EDT" INFO [2024-07-30T20:10:51-04:00] ID: 9973b89c-eb37-47f2-a366-6107b1155dda, Class: websocket, Description: Executing command CreatedAt="2024-07-30 20:10:51.264352731 -0400 EDT" Err= Location=none MayCancel=false Metadata="map[command:[free -h] environment:map[HOME:/root LANG:C.UTF-8 PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin TERM:xterm-256color USER:root] fds:map[0:a72a1819ae4b994178c9996cea67caa925c5bb3ea3515defc796825cda0cd329 control:13992b728b32f8d7601c1c9d8579811d3c337482e408c87592e9f1dfd0cc45f2] interactive:true]" Resources="map[instances:[/1.0/instances/limited]]" Status=Running StatusCode=Running UpdatedAt="2024-07-30 20:10:51.264352731 -0400 EDT" DEBUG [2024-07-30T20:10:51-04:00] Waiting for exec websockets to connect"
DEBUG [2024-07-30T20:10:51-04:00] Instance process stopped PID=25058 err="" exitStatus=0 instance=limited interactive=true project=default
DEBUG [2024-07-30T20:10:51-04:00] Exec control handler finished PID=25058 instance=limited interactive=true project=default
DEBUG [2024-07-30T20:10:51-04:00] Websocket: Sending barrier message address=@
DEBUG [2024-07-30T20:10:51-04:00] Websocket: Stopped write mirror address=@ err="websocket: close 1006 (abnormal closure): unexpected EOF"
DEBUG [2024-07-30T20:10:51-04:00] Exec mirror websocket finished PID=25058 instance=limited interactive=true number=0 project=default readErr="" writeErr="websocket: close 1006 (abnormal closure): unexpected EOF"
DEBUG [2024-07-30T20:10:51-04:00] Updated metadata for operation class=websocket description="Executing command" operation=9973b89c-eb37-47f2-a366-6107b1155dda project=default
DEBUG [2024-07-30T20:10:51-04:00] Success for operation class=websocket description="Executing command" operation=9973b89c-eb37-47f2-a366-6107b1155dda project=default
INFO [2024-07-30T20:10:51-04:00] ID: 9973b89c-eb37-47f2-a366-6107b1155dda, Class: websocket, Description: Executing command CreatedAt="2024-07-30 20:10:51.264352731 -0400 EDT" Err= Location=none MayCancel=false Metadata="map[command:[free -h] environment:map[HOME:/root LANG:C.UTF-8 PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin TERM:xterm-256color USER:root] fds:map[0:a72a1819ae4b994178c9996cea67caa925c5bb3ea3515defc796825cda0cd329 control:13992b728b32f8d7601c1c9d8579811d3c337482e408c87592e9f1dfd0cc45f2] interactive:true return:0]" Resources="map[instances:[/1.0/instances/limited]]" Status=Running StatusCode=Running UpdatedAt="2024-07-30 20:10:51.538228811 -0400 EDT"
INFO [2024-07-30T20:10:51-04:00] ID: 9973b89c-eb37-47f2-a366-6107b1155dda, Class: websocket, Description: Executing command CreatedAt="2024-07-30 20:10:51.264352731 -0400 EDT" Err= Location=none MayCancel=false Metadata="map[command:[free -h] environment:map[HOME:/root LANG:C.UTF-8 PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin TERM:xterm-256color USER:root] fds:map[0:a72a1819ae4b994178c9996cea67caa925c5bb3ea3515defc796825cda0cd329 control:13992b728b32f8d7601c1c9d8579811d3c337482e408c87592e9f1dfd0cc45f2] interactive:true return:0]" Resources="map[instances:[/1.0/instances/limited]]" Status=Success StatusCode=Success UpdatedAt="2024-07-30 20:10:51.538228811 -0400 EDT"
DEBUG [2024-07-30T20:10:51-04:00] Event listener server handler stopped listener=be90c4cf-6bf6-4d89-ae93-9285b88ec3d5 local=/spare/incus-6.0/data/unix.socket remote=@
DEBUG [2024-07-30T20:10:51-04:00] Handling API request ip=@ method=GET protocol=unix url="/1.0/operations/9973b89c-eb37-47f2-a366-6107b1155dda/websocket?secret=13992b728b32f8d7601c1c9d8579811d3c337482e408c87592e9f1dfd0cc45f2" username=adavis DEBUG [2024-07-30T20:10:51-04:00] Connected to operation class=websocket description="Executing command" operation=9973b89c-eb37-47f2-a366-6107b1155dda project=default DEBUG [2024-07-30T20:10:51-04:00] Connecting to operation class=websocket description="Executing command" operation=9973b89c-eb37-47f2-a366-6107b1155dda project=default DEBUG [2024-07-30T20:10:51-04:00] Connecting to operation class=websocket description="Executing command" operation=9973b89c-eb37-47f2-a366-6107b1155dda project=default DEBUG [2024-07-30T20:10:51-04:00] Handling API request ip=@ method=GET protocol=unix url="/1.0/operations/9973b89c-eb37-47f2-a366-6107b1155dda/websocket?secret=a72a1819ae4b994178c9996cea67caa925c5bb3ea3515defc796825cda0cd329" username=adavis DEBUG [2024-07-30T20:10:51-04:00] Connected to operation class=websocket description="Executing command" operation=9973b89c-eb37-47f2-a366-6107b1155dda project=default DEBUG [2024-07-30T20:10:51-04:00] Handling API request ip=@ method=GET protocol=unix url=/1.0/operations/9973b89c-eb37-47f2-a366-6107b1155dda username=adavis INFO [2024-07-30T20:10:51-04:00] Action: instance-exec, Source: /1.0/instances/limited command="[free -h]" DEBUG [2024-07-30T20:10:51-04:00] Retrieved PID of executing child process attachedPid=25058 instance=limited instanceType=container project=default DEBUG [2024-07-30T20:10:51-04:00] Instance process started PID=25058 instance=limited interactive=true project=default DEBUG [2024-07-30T20:10:51-04:00] Exec mirror websocket started PID=25058 instance=limited interactive=true number=0 project=default DEBUG [2024-07-30T20:10:51-04:00] Exec control handler started PID=25058 instance=limited interactive=true project=default DEBUG [2024-07-30T20:10:51-04:00] Websocket: Started write mirror address=@ DEBUG [2024-07-30T20:10:51-04:00] Websocket: Started read mirror address=@ DEBUG [2024-07-30T20:10:51-04:00] Websocket: Stopped read mirror address=@ err="