From cceb9a2ed1e61af2bd2743c257b0045690b95519 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= <valtri@civ.zcu.cz>
Date: Thu, 12 Sep 2024 13:57:34 +0000
Subject: [PATCH] Tune deployment script - waiting for pods

---
 cesnet-central/deploy.sh | 2 +-
 cesnet-mcc/deploy.sh     | 2 +-
 production2/deploy.sh    | 2 +-
 staging1/deploy.sh       | 4 ++--
 staging2/deploy.sh       | 4 ++--
 testing/deploy.sh        | 4 ++--
 6 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/cesnet-central/deploy.sh b/cesnet-central/deploy.sh
index 764f9c6..16cc881 100755
--- a/cesnet-central/deploy.sh
+++ b/cesnet-central/deploy.sh
@@ -26,6 +26,6 @@ ansible-playbook playbooks/squid.yaml
 ansible-playbook playbooks/cvmfs.yaml
 
 # wait for finish
-while ansible -m command -a 'kubectl get pods --all-namespaces' master | tail -n +3 | grep -v ' Running '; do sleep 5; done
+while ansible -m command -a 'kubectl get pods --all-namespaces' master | tail -n +3 | grep -Ev ' (Running|Completed) '; do sleep 5; done
 
 ansible-playbook playbooks/security-logs.yaml
diff --git a/cesnet-mcc/deploy.sh b/cesnet-mcc/deploy.sh
index 2d30999..d051d3d 100755
--- a/cesnet-mcc/deploy.sh
+++ b/cesnet-mcc/deploy.sh
@@ -46,7 +46,7 @@ ansible -m command -a '/root/squid-volume.sh' 'ingress[0]'
 ansible-playbook playbooks/k8s.yaml
 # ansible-playbook playbooks/squid.yaml
 # ansible-playbook playbooks/cvmfs.yaml
-while ansible -i ./inventory -m command -a 'kubectl get pods --all-namespaces' master | tail -n +3 | grep -v ' Running '; do sleep 5; done
+while ansible -m command -a 'kubectl get pods --all-namespaces' master | tail -n +3 | grep -Ev ' (Running|Completed) '; do sleep 5; done
 # docker runtime directory after Kubernetes deployment (problem with unmounts)
 ansible -m copy -a 'src=terraform/docker-volume.sh dest=/root/ mode=preserve' 'ingress nfs worker gpu'
 ansible -m command -a '/root/docker-volume.sh' 'ingress nfs worker gpu'
diff --git a/production2/deploy.sh b/production2/deploy.sh
index c64fa1c..5c6b5dd 100755
--- a/production2/deploy.sh
+++ b/production2/deploy.sh
@@ -44,7 +44,7 @@ ansible -m command -a '/root/squid-volume.sh' 'ingress[0]'
 
 # kubernetes
 ansible-playbook playbooks/k8s.yaml
-while ansible -i ./inventory -m command -a 'kubectl get pods --all-namespaces' master | tail -n +3 | grep -v ' Running '; do sleep 5; done
+while ansible -m command -a 'kubectl get pods --all-namespaces' master | tail -n +3 | grep -Ev ' (Running|Completed) '; do sleep 5; done
 # docker runtime directory after Kubernetes deployment (problem with unmounts)
 ansible -m copy -a 'src=terraform/docker-volume.sh dest=/root/ mode=preserve' 'ingress nfs worker gpu'
 ansible -m command -a '/root/docker-volume.sh' 'ingress nfs worker gpu'
diff --git a/staging1/deploy.sh b/staging1/deploy.sh
index 2487b4b..d87a2ea 100755
--- a/staging1/deploy.sh
+++ b/staging1/deploy.sh
@@ -44,7 +44,7 @@ ansible -m command -a '/root/squid-volume.sh' 'ingress[0]'
 
 # kubernetes
 ansible-playbook playbooks/k8s.yaml
-while ansible -i ./inventory -m command -a 'kubectl get pods --all-namespaces' master | tail -n +3 | grep -v ' Running '; do sleep 5; done
+while ansible -m command -a 'kubectl get pods --all-namespaces' master | tail -n +3 | grep -Ev ' (Running|Completed) '; do sleep 5; done
 # docker runtime directory after Kubernetes deployment (problem with unmounts)
 ansible -m copy -a 'src=terraform/docker-volume.sh dest=/root/ mode=preserve' 'ingress nfs worker gpu'
 ansible -m command -a '/root/docker-volume.sh' 'ingress nfs worker gpu'
@@ -52,7 +52,7 @@ ansible-playbook playbooks/squid.yaml
 ansible-playbook playbooks/cvmfs.yaml
 
 # wait for finish
-while ansible -m command -a 'kubectl get pods --all-namespaces' master | tail -n +3 | grep -v ' Running '; do sleep 5; done
+while ansible -m command -a 'kubectl get pods --all-namespaces' master | tail -n +3 | grep -Ev ' (Running|Completed) '; do sleep 5; done
 
 ansible-playbook playbooks/security-assets.yaml
 ansible-playbook playbooks/security-logs.yaml
diff --git a/staging2/deploy.sh b/staging2/deploy.sh
index f31cfb5..64c1ce2 100755
--- a/staging2/deploy.sh
+++ b/staging2/deploy.sh
@@ -44,7 +44,7 @@ ansible -m command -a '/root/squid-volume.sh' 'ingress[0]'
 
 # kubernetes
 ansible-playbook playbooks/k8s.yaml
-while ansible -i ./inventory -m command -a 'kubectl get pods --all-namespaces' master | tail -n +3 | grep -v ' Running '; do sleep 5; done
+while ansible -m command -a 'kubectl get pods --all-namespaces' master | tail -n +3 | grep -Ev ' (Running|Completed) '; do sleep 5; done
 # docker runtime directory after Kubernetes deployment (problem with unmounts)
 ansible -m copy -a 'src=terraform/docker-volume.sh dest=/root/ mode=preserve' 'ingress nfs worker gpu'
 ansible -m command -a '/root/docker-volume.sh' 'ingress nfs worker gpu'
@@ -52,4 +52,4 @@ ansible-playbook playbooks/squid.yaml
 ansible-playbook playbooks/cvmfs.yaml
 
 # wait for finish
-while ansible -m command -a 'kubectl get pods --all-namespaces' master | tail -n +3 | grep -v ' Running '; do sleep 5; done
+while ansible -m command -a 'kubectl get pods --all-namespaces' master | tail -n +3 | grep -Ev ' (Running|Completed) '; do sleep 5; done
diff --git a/testing/deploy.sh b/testing/deploy.sh
index 4f42d6e..d7ac3c0 100755
--- a/testing/deploy.sh
+++ b/testing/deploy.sh
@@ -46,7 +46,7 @@ ansible -m command -a '/root/scratch-volume.sh' 'ingress nfs worker gpu'
 
 # kubernetes
 ansible-playbook playbooks/k8s.yaml
-while ansible -i ./inventory -m command -a 'kubectl get pods --all-namespaces' master | tail -n +3 | grep -v ' Running '; do sleep 5; done
+while ansible -m command -a 'kubectl get pods --all-namespaces' master | tail -n +3 | grep -Ev ' (Running|Completed) '; do sleep 5; done
 # docker runtime directory after Kubernetes deployment (problem with unmounts)
 ansible -m copy -a 'src=terraform/docker-volume.sh dest=/root/ mode=preserve' 'ingress nfs worker gpu'
 ansible -m command -a '/root/docker-volume.sh' 'ingress nfs worker gpu'
@@ -54,4 +54,4 @@ ansible-playbook playbooks/squid.yaml
 ansible-playbook playbooks/cvmfs.yaml
 
 # wait for finish
-while ansible -m command -a 'kubectl get pods --all-namespaces' master | tail -n +3 | grep -v ' Running '; do sleep 5; done
+while ansible -m command -a 'kubectl get pods --all-namespaces' master | tail -n +3 | grep -Ev ' (Running|Completed) '; do sleep 5; done
-- 
GitLab