Skip to content

Commit

Permalink
bugfix: plus default_memory when calculating mem size
Browse files Browse the repository at this point in the history
We've noticed this caused regressions with the k8s-oom tests, and then
decided to take a step back and do this in the same way it was done
before 67972ec.

Moreover, this step back is also more reasonable in terms of the
controlling logic.

And by doing this we can re-enable the k8s-oom.bats tests, which is done
as part of this PR.

Fixes: kata-containers#7271
Depends-on: github.com/kata-containers/tests#5705

Signed-off-by: Yushuo <[email protected]>
  • Loading branch information
YushuoEdge authored and studychao committed Aug 22, 2023
1 parent 9e75870 commit 9da6f1d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 6 additions & 1 deletion src/runtime-rs/crates/resource/src/cpu_mem/initial_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ impl InitialSizeManager {
hv.cpu_info.default_vcpus = self.resource.vcpu as i32
}
if self.resource.mem_mb > 0 {
hv.memory_info.default_memory = self.resource.mem_mb;
// since the memory overhead introduced by kata-agent and system components
// will really affect the amount of memory the user can use, so we choose to
// plus the default_memory here, instead of overriding it.
// (if we override the default_memory here, and user apllications still
// use memory as they orignally expected, it would be easy to OOM.)
hv.memory_info.default_memory += self.resource.mem_mb;
}
Ok(())
}
Expand Down
6 changes: 0 additions & 6 deletions tests/integration/kubernetes/k8s-oom.bats
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@ load "${BATS_TEST_DIRNAME}/../../common.bash"
load "${BATS_TEST_DIRNAME}/tests_common.sh"

setup() {
[ "${KATA_HYPERVISOR}" == "dragonball" ] && skip "Test is currently failing, see: https://github.com/kata-containers/kata-containers/issues/7271"

pod_name="pod-oom"
get_pod_config_dir
}

@test "Test OOM events for pods" {
[ "${KATA_HYPERVISOR}" == "dragonball" ] && skip "Test is currently failing, see: https://github.com/kata-containers/kata-containers/issues/7271"

# Create pod
kubectl create -f "${pod_config_dir}/$pod_name.yaml"

Expand All @@ -33,8 +29,6 @@ setup() {
}

teardown() {
[ "${KATA_HYPERVISOR}" == "dragonball" ] && skip "Test is currently failing, see: https://github.com/kata-containers/kata-containers/issues/7271"

# Debugging information
kubectl describe "pod/$pod_name"
kubectl get "pod/$pod_name" -o yaml
Expand Down

0 comments on commit 9da6f1d

Please sign in to comment.