From 6a2e97003dc4f497734e52dcfab1bf75604ac694 Mon Sep 17 00:00:00 2001
From: Vineet Reddy Rajula <rajula.vineet.reddy@cern.ch>
Date: Fri, 13 Aug 2021 13:01:59 +0200
Subject: [PATCH] Hotfix: Add timeout to 'oc wait'

---
 chart/drupal-operations/templates/clear-cache.yaml        | 2 +-
 chart/drupal-operations/templates/database-restore.yaml   | 2 +-
 chart/drupal-operations/templates/drupalsite-restore.yaml | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/chart/drupal-operations/templates/clear-cache.yaml b/chart/drupal-operations/templates/clear-cache.yaml
index 32acc84..36d16fb 100644
--- a/chart/drupal-operations/templates/clear-cache.yaml
+++ b/chart/drupal-operations/templates/clear-cache.yaml
@@ -32,7 +32,7 @@ spec:
         export NAMESPACE=$(params.namespace)
         export SERVING_POD_IMAGE=$(oc get -n "$NAMESPACE" "drupalsite/$DRUPALSITE" -o=jsonpath='{.status.servingPodImage}')
         envsubst < /tekton-task-templates/drupal_operation_job.yaml | oc create -n "$NAMESPACE" -f -
-        oc wait --for=condition=complete "job/$TASK-$DRUPALSITE"
+        oc wait --timeout=1h --for=condition=complete "job/$TASK-$DRUPALSITE" -n "$NAMESPACE"
         jobStatus=$(oc get "job/$TASK-$DRUPALSITE" -o=jsonpath='{.status.conditions[*].type}' | grep -i -E 'failed|complete' || echo "Failed")
         echo "Job status: $jobStatus"
         echo "Job logs:"
diff --git a/chart/drupal-operations/templates/database-restore.yaml b/chart/drupal-operations/templates/database-restore.yaml
index 3e9f4ed..699426a 100644
--- a/chart/drupal-operations/templates/database-restore.yaml
+++ b/chart/drupal-operations/templates/database-restore.yaml
@@ -33,7 +33,7 @@ spec:
         export NAMESPACE=$(params.namespace)
         export SERVING_POD_IMAGE=$(oc get -n $NAMESPACE drupalsite/$DRUPALSITE -o=jsonpath='{.status.servingPodImage}')
         envsubst < /tekton-task-templates/drupal_operation_job.yaml | oc create -n $NAMESPACE -f -
-        oc wait --for=condition=complete job/$TASK-$DRUPALSITE
+        oc wait --timeout=1h --for=condition=complete job/$TASK-$DRUPALSITE -n "$NAMESPACE"
         jobStatus=$(oc get job/$TASK-$DRUPALSITE -o=jsonpath='{.status.conditions[*].type}' | grep -i -E 'failed|complete' || echo "Failed")
         echo "Job status: $jobStatus"
         echo "Job logs:"
diff --git a/chart/drupal-operations/templates/drupalsite-restore.yaml b/chart/drupal-operations/templates/drupalsite-restore.yaml
index 8fe740f..a185c08 100644
--- a/chart/drupal-operations/templates/drupalsite-restore.yaml
+++ b/chart/drupal-operations/templates/drupalsite-restore.yaml
@@ -37,7 +37,7 @@ spec:
         export OPERATIONS_IMAGE={{ .Values.image }}
         export RESTORE_SERVICE_ACCOUNT={{ .Values.restoreServiceAccount }}
         envsubst < /tekton-task-templates/restore_pv_job.yaml | oc create -f -
-        oc wait --for=condition=complete "job/$TASK-$DRUPALSITE" -n "$VELERO_NAMESPACE"
+        oc wait --timeout=1h --for=condition=complete "job/$TASK-$DRUPALSITE" -n "$VELERO_NAMESPACE"
         jobStatus=$(oc get job/$TASK-$DRUPALSITE -n $VELERO_NAMESPACE -o=jsonpath='{.status.conditions[*].type}' | grep -i -E 'failed|complete' || echo "Failed")
         echo "Files restore Job status: $jobStatus"
         echo "Files restore Job logs:"
@@ -51,7 +51,7 @@ spec:
         export OPERATION="database-restore"
         export ARGS="-f 'database_backup.sql'"
         envsubst < /tekton-task-templates/drupal_operation_job.yaml | oc create -n "$NAMESPACE" -f -
-        oc wait --for=condition=complete job/$TASK-$DRUPALSITE
+        oc wait --timeout=1h --for=condition=complete job/$TASK-$DRUPALSITE -n "$NAMESPACE"
         jobStatus=$(oc get job/$TASK-$DRUPALSITE -o=jsonpath='{.status.conditions[*].type}' | grep -i -E 'failed|complete' || echo "Failed")
         echo "Database restore Job status: $jobStatus"
         echo "Database restore Job logs:"
-- 
GitLab