From eb8fe6a28be96fa6d6659e67e8ccf15f594eb1b3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= <valtri@civ.zcu.cz>
Date: Fri, 21 Jun 2024 16:38:21 +0000
Subject: [PATCH] Enable regular cleaning of stuck kubernetes pods notebooks

---
 cesnet-central/playbooks/notebooks.yaml | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/cesnet-central/playbooks/notebooks.yaml b/cesnet-central/playbooks/notebooks.yaml
index 89c48ab..119e676 100644
--- a/cesnet-central/playbooks/notebooks.yaml
+++ b/cesnet-central/playbooks/notebooks.yaml
@@ -118,6 +118,19 @@
       with_fileglob:
         - "../extra/*.yaml"
       when: true
+    # Workaround for pods stuck in "Terminating" state
+    - name: Regular cleanup of failed user notebooks pods
+      vars:
+        name: "{{ item | basename | splitext | first }}"
+      cron:
+        cron_file: "notebooks-{{ name }}-cleaner"
+        name: "Notebooks {{ name }} cleanup"
+        minute: "*/2"
+        hour: "*"
+        job: "KUBECONFIG=$HOME/.kube/config /usr/local/bin/k8s-pods-cleaner.sh '{{ name }}' app=jupyterhub,component=singleuser-server --yes >/dev/null 2>&1"
+        user: egi
+      with_fileglob:
+        - "../deployments/*.yaml"
 - hosts: nfs
   become: true
   tasks:
-- 
GitLab