From e0fa13f451ed65a375b6410dbf97aefe708392a0 Mon Sep 17 00:00:00 2001 From: Daniel Pawlik Date: Fri, 14 Jun 2024 12:14:04 +0200 Subject: [PATCH] Print warning when OOMKiller occured By making tests with new MicroShfit release, some of our pods from time to time got OOMKill, that later disturb the tests. This commit will print a warning, when the pod was killed by the OOMKiller, so we can increase the resources. Change-Id: I10d7163f20486e9764d2f8b51c8aa0301b05995e --- roles/post/get-k8s-cluster-resources/tasks/main.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/roles/post/get-k8s-cluster-resources/tasks/main.yaml b/roles/post/get-k8s-cluster-resources/tasks/main.yaml index c5646bfd..776ec7ce 100644 --- a/roles/post/get-k8s-cluster-resources/tasks/main.yaml +++ b/roles/post/get-k8s-cluster-resources/tasks/main.yaml @@ -37,3 +37,14 @@ - pv tags: skip_ansible_lint + +- name: Check if some pod was OOMKilled + ansible.builtin.shell: | + kubectl get events --all-namespaces --sort-by='.lastTimestamp' -A | grep -i oom | tee {{ output_dir }}/oomkilled.log + register: _oomkill_status + ignore_errors: true + +- name: Print warning message when OOMKill occured + ansible.builtin.shell: | + echo -e "\n\n\n\nOOMKill occured!\n{{ _oomkill_status.stdout }}\n\n\n\n" + when: _oomkill_status.stdout | length > 0