Use default memory stats instead of panic.#116
Use default memory stats instead of panic.#116fidencio merged 3 commits intokata-containers:mainfrom
Conversation
When containers are terminated, cgroup v2 memory metrics under /sys/fs/cgroup may disappear. Previously, kata-agent assumed these metrics always exist, leading to panics as reported in kata-containers#138. This commit returns default value (0) when memory metric files are missing. This behaviour aligns with cgroup v1, which also defaults to 0 memory metric files are missing: - Memory.limit_in_bytes which maps to m.max https://github.com/kata-containers/cgroups-rs/blob/main/src/memory.rs#L635 - Memory.soft_limit_in_bytes which maps to m.low https://github.com/kata-containers/cgroups-rs/blob/main/src/memory.rs#L661 - MemSwap.fail_cnt: https://github.com/kata-containers/cgroups-rs/blob/main/src/memory.rs#L631 Submitting a new PR because kata-containers#116 does not handle MemSwap.fail_cnt, which will also cause panic.
When containers are terminated, cgroup v2 memory metrics under /sys/fs/cgroup may disappear. Previously, kata-agent assumed these metrics always exist, leading to panics as reported in kata-containers#138. This commit returns default value (0) when memory metric files are missing. This behaviour aligns with cgroup v1, which also defaults to 0 memory metric files are missing: - Memory.limit_in_bytes which maps to m.max https://github.com/kata-containers/cgroups-rs/blob/main/src/memory.rs#L635 - Memory.soft_limit_in_bytes which maps to m.low https://github.com/kata-containers/cgroups-rs/blob/main/src/memory.rs#L661 - MemSwap.fail_cnt: https://github.com/kata-containers/cgroups-rs/blob/main/src/memory.rs#L631 Submitting a new PR because kata-containers#116 does not handle MemSwap.fail_cnt, which will also cause panic.
When containers are terminated, cgroup v2 memory metrics under /sys/fs/cgroup may disappear. Previously, kata-agent assumed these metrics always exist, leading to panics as reported in kata-containers#138. This commit returns default value (0) when memory metric files are missing. This behaviour aligns with cgroup v1, which also defaults to 0 memory metric files are missing: - Memory.limit_in_bytes which maps to m.max https://github.com/kata-containers/cgroups-rs/blob/main/src/memory.rs#L635 - Memory.soft_limit_in_bytes which maps to m.low https://github.com/kata-containers/cgroups-rs/blob/main/src/memory.rs#L661 - MemSwap.fail_cnt: https://github.com/kata-containers/cgroups-rs/blob/main/src/memory.rs#L631 Submitting a new PR because kata-containers#116 does not handle MemSwap.fail_cnt, which will also cause panic. Signed-off-by: Alex Man <alexman@stripe.com>
When containers are terminated, cgroup v2 memory metrics under /sys/fs/cgroup may disappear. Previously, kata-agent assumed these metrics always exist, leading to panics as reported in kata-containers#138. This commit returns default value (0) when memory metric files are missing. This behaviour aligns with cgroup v1, which also defaults to 0 memory metric files are missing: - Memory.limit_in_bytes which maps to m.max https://github.com/kata-containers/cgroups-rs/blob/main/src/memory.rs#L635 - Memory.soft_limit_in_bytes which maps to m.low https://github.com/kata-containers/cgroups-rs/blob/main/src/memory.rs#L661 - MemSwap.fail_cnt: https://github.com/kata-containers/cgroups-rs/blob/main/src/memory.rs#L631 Submitting a new PR because kata-containers#116 does not handle MemSwap.fail_cnt, which will also cause panic. Signed-off-by: Alex Man <alexman@stripe.com>
It is not appropriate to use |
Yeah, I agree, it should keep align with it's default value defined in the cgroup v2 instead of "max" value. |
I've adjusted to the actual default values. |
3cccfc8 to
75887f3
Compare
I'm not fmiliar with this crate, so let's just ignore the warning for now instead of removing the code. Signed-off-by: Fabiano Fidêncio <fidencio@northflank.com>
When containers are terminated, cgroup v2 memory metrics under /sys/fs/cgroup may disappear. Previously, kata-agent assumed these metrics always exist, leading to panics as reported in kata-containers#138. This commit returns default value (0) when memory metric files are missing. This behaviour aligns with cgroup v1, which also defaults to 0 memory metric files are missing: - Memory.limit_in_bytes which maps to m.max https://github.com/kata-containers/cgroups-rs/blob/main/src/memory.rs#L635 - Memory.soft_limit_in_bytes which maps to m.low https://github.com/kata-containers/cgroups-rs/blob/main/src/memory.rs#L661 - MemSwap.fail_cnt: https://github.com/kata-containers/cgroups-rs/blob/main/src/memory.rs#L631 Signed-off-by: Ruini Xue <ruini.xue@gmail.com> Signed-off-by: Alex Man <alexman@stripe.com> Signed-off-by: Fabiano Fidêncio <fidencio@northflank.com>
Otherwise it simply breaks. Signed-off-by: Alex Man <alexman@stripe.com> Signed-off-by: Fabiano Fidêncio <fidencio@northflank.com>
|
/retest |
|
For some reason the WIP and Commit Message Checks are not running. Thanks for the reviews. |
If either
memory.high,memory.low,memory.max, ormemory.minis not available in V2, the current code will panic, which might break user applications unintentionally. This PR tries to return the default value instead.