Closed pmores closed 4 months ago
@kata-containers/architecture-committee Could you guys help me tag folks who have knowledge of these parts of runtime-rs and might be able to offer insights?
I verified that when I try the same (analogous) thing with a pod (just using the io.kubernetes.cri.sandbox-memory
annotation now) I get the expected result - the VM starts with 2G of coldplugged memory, followed by a resize_memory()
call with 7168, or 7G (2G + 5G), as the argument.
Hi @pmores
I'll take it.
Thanks a lot @lifupan , please tag me if you submit a PR!
I verified that when I try the same (analogous) thing with a pod (just using the
io.kubernetes.cri.sandbox-memory
annotation now) I get the expected result - the VM starts with 2G of coldplugged memory, followed by aresize_memory()
call with 7168, or 7G (2G + 5G), as the argument.
Hm, as an update after observing this some more, it's however possible even in the pod scenario to end up with 12G (default_memory
+ 2 * sandbox-memory
) of coldplugged memory. Then the Hypervisor
get a resize_memory()
to 7G.
I'm increasingly confused. :-)
Hi @pmores
Can you double check whether this PR. https://github.com/kata-containers/kata-containers/pull/9836 fixed your issue?
Description of problem
I run a single kata container with a 5G memory limit (
ctr run --memory-limit 5368709120
) while havingin my
configuration.toml
.Expected result
I expected to get a qemu VM with 2G of coldplugged memory and a call to
Qemu::resize_memory()
to handle the memory limit.Actual result
I got a qemu VM with 12G of coldplugged memory and a
resize_memory()
call to resize memory to 12288 (12G).Further information
The coldplugged memory size seems to come from
InitialSizeManager
implementation which, at least in a single container case, adds the memory limit size todefault_memory
and stores the result back in the config. This also happens twice since runtime-rs appears to be processing a Create request twice(*).The double call along with the non-idempotency of
InitialSizeManager
seems to explain the 12G of coldplugged memory (qemu sees 2G + 5G + 5G = 12G indefault_memory
in hypervisor config).I have no idea about the
resize_memory()
to resize memory to the amount it already has.(*) Relevant part of the callstack (same in both calls):