mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-01 07:47:15 +00:00
tests: Prevent the shim from being killed in k8s-oom test
The actual memory usage on the host is equal to the hypervisor memory usage plus the user memory usage. An OOM killer might kill the shim when the memory limit on host is same with that of container and the container consumes all available memory. In this case, the containerd will never receive OOM event, but get "task exit" event. That makes the `k8s-oom.bats` test fail. The fix is to add a new container to increase the sandbox memory limit. When the container "oom-test" is killed by OOM killer, there is still available memory for the shim, so it will not be killed. Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
This commit is contained in:
parent
635272f3e8
commit
6aa3517393
@ -24,7 +24,12 @@ setup() {
|
||||
kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name"
|
||||
|
||||
# Check if OOMKilled
|
||||
cmd="kubectl get pods "$pod_name" -o jsonpath='{.status.containerStatuses[0].state.terminated.reason}' | grep OOMKilled"
|
||||
container_name=$(kubectl get pod "$pod_name" -o jsonpath='{.status.containerStatuses[0].name}')
|
||||
if [[ $container_name == "oom-test" ]]; then
|
||||
cmd="kubectl get pods "$pod_name" -o jsonpath='{.status.containerStatuses[0].state.terminated.reason}' | grep OOMKilled"
|
||||
else
|
||||
cmd="kubectl get pods "$pod_name" -o jsonpath='{.status.containerStatuses[1].state.terminated.reason}' | grep OOMKilled"
|
||||
fi
|
||||
|
||||
waitForProcess "$wait_time" "$sleep_time" "$cmd"
|
||||
|
||||
|
@ -17,6 +17,16 @@ spec:
|
||||
name: oom-test
|
||||
command: ["/bin/sh"]
|
||||
args: ["-c", "sleep 2; stress --vm 2 --vm-bytes 500M --timeout 30s"]
|
||||
resources:
|
||||
limits:
|
||||
memory: 400Mi
|
||||
requests:
|
||||
memory: 400Mi
|
||||
- image: quay.io/kata-containers/sysbench-kata:latest
|
||||
imagePullPolicy: IfNotPresent
|
||||
name: not-oom
|
||||
command: ["/bin/sh"]
|
||||
args: ["-c", "sleep inf"]
|
||||
resources:
|
||||
limits:
|
||||
memory: 500Mi
|
||||
|
Loading…
Reference in New Issue
Block a user