Closed rosbeef closed 2 years ago
Bouncing to lxcfs as it's not an actual LXD issue. I also seem to recall that it's a deliberate behavior of LXCFS as there's no better way to report this currently.
Basically, LXD sets up the swap under cgroup1 and cgroup2 to be 0
bytes.
That doesn't actually mean no swap, it means no ADDITIONAL memory can be taken from swap. The total container allocation itself as set through memory limits can come from either swap or from main memory.
We tried some approaches to report that in the past, but it's very tricky. Basically we know how much memory is used from swap and we know the total amount of memory the instance can use (ram+swap). But there is no fixed bucket of ram and fixed bucket of swap, which makes it impossible to report through the normal files.
In past LXCFS versions, we'd lie and always report the host swap as the swap and then report the container usage against that. But that had two issues:
As a result, in such situations, LXCFS will simply not report the swap at all. You'll typically only find accurate swap reporting when no memory limit is applied to the container as in that case we can safely expose the host values and have everything line up nicely.
https://github.com/lxc/lxcfs#swap-handling has some more details
nice to view your complete a clear answer. i can close this
Required information
Distribution: Description: Debian GNU/Linux 11 (bullseye)
More details Linux gre 5.4.199-odroidxu4 lxc/lxd#22.05.3 SMP PREEMPT Wed Jun 22 07:29:40 UTC 2022 armv7l
The output of "lxc info" or if that fails:
Issue description
no swap inside my container
Steps to reproduce
create container the free -hin the container show no swap available
Information to attach
dmesg
)Kernel command line: console=ttySAC2,115200n8 console=tty1 consoleblank=0 loglevel=1 root=UUID=50536e32-d033-4595-bfcd-113e6053042e rootfstype=btrfs rootwait rw smsc95xx.macaddr=00:xxx55 governor=performance hdmi_tx_amp_lvl=31 hdmi_tx_lvl_ch0=3 hdmi_tx_lvl_ch1=3 hdmi_tx_lvl_ch2=3 hdmi_tx_emp_lvl=6 hdmi_clk_amp_lvl=31 hdmi_tx_res=0 HPD=true vout=hdmi usb-storage.quirks=0x2537:0x1066:u,0x2537:0x1068:u swapaccount=1 cgroup_enable=memory cgroup_memory=1
lxc info NAME --show-log
)Resources: Processes: 6 CPU usage: CPU usage (in seconds): 16 Memory usage: Memory (current): 19.95MiB Network usage: eth0: Type: broadcast State: UP Host interface: enx00xxx6b6 MAC address: 00:xxx:2e MTU: 1500 Bytes received: 3.45kB Bytes sent: 2.31kB Packets received: 24 Packets sent: 23 IP addresses: inet: 192.168.0.153/24 (global) inet6: 2a01:xxx:7b2e/64 (global) inet6: fe80:xxx:7b2e/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 yunh1 20220815212056.933 WARN conf - ../src/src/lxc/conf.c:lxc_map_ids:3592 - newuidmap binary is missing lxc yunh1 20220815212056.934 WARN conf - ../src/src/lxc/conf.c:lxc_map_ids:3598 - newgidmap binary is missing lxc yunh1 20220815212056.936 WARN conf - ../src/src/lxc/conf.c:lxc_map_ids:3592 - newuidmap binary is missing lxc yunh1 20220815212056.937 WARN conf - ../src/src/lxc/conf.c:lxc_map_ids:3598 - newgidmap binary is missing lxc yunh1 20220815212104.254 WARN conf - ../src/src/lxc/conf.c:lxc_map_ids:3592 - newuidmap binary is missing lxc yunh1 20220815212104.255 WARN conf - ../src/src/lxc/conf.c:lxc_map_ids:3598 - newgidmap binary is missing
/snap/bin/lxc config show yunh1 --expanded architecture: armv7l config: image.architecture: armhf image.description: Debian buster armhf (20220815_05:25) image.os: Debian image.release: buster image.serial: "20220815_05:25" image.type: squashfs image.variant: default limits.memory.swap: "true" security.syscalls.intercept.sysinfo: "true" volatile.base_image: 888106799c2e7b4a3ed66b5a0a5e32e53a65bdadabaf25e03adf80f71fabb1a2 volatile.cloud-init.instance-id: 89bafb63-157e-4f67-b6b5-b1c188f3048a volatile.eth0.host_name: mace6df26bd volatile.eth0.hwaddr: 00:1xxx:2e volatile.eth0.last_state.created: "false" volatile.eth0.name: eth0 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: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]' volatile.last_state.power: RUNNING volatile.uuid: d1606124-a0ca-4479-9e6f-2491e9a5d497 devices: eth0: nictype: macvlan parent: enx001e063686b6 type: nic root: path: / pool: default type: disk ephemeral: false profiles: