From dbd45d20e6939de67d298a364d1cf10ee8ec87d1 Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Wed, 24 Jan 2024 16:05:06 +1100 Subject: [PATCH] change: improve message and fail sooner on failure to provision dbaas (#203) --- legacy/scripts/exec-kubectl-mariadb-dbaas.sh | 9 +++++++-- legacy/scripts/exec-kubectl-mongodb-dbaas.sh | 9 +++++++-- legacy/scripts/exec-kubectl-postgres-dbaas.sh | 9 +++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/legacy/scripts/exec-kubectl-mariadb-dbaas.sh b/legacy/scripts/exec-kubectl-mariadb-dbaas.sh index d89a8380..d3cefe42 100644 --- a/legacy/scripts/exec-kubectl-mariadb-dbaas.sh +++ b/legacy/scripts/exec-kubectl-mariadb-dbaas.sh @@ -1,13 +1,18 @@ #!/bin/bash # The operator can sometimes take a bit, wait until the details are available -# We added a timeout of 10 minutes (120 retries) before exit +# We added a timeout of 5 minutes (60 retries) before exit OPERATOR_COUNTER=1 -OPERATOR_TIMEOUT=180 +OPERATOR_TIMEOUT=60 # use the secret name from the consumer to prevent credential clash until kubectl -n ${NAMESPACE} get mariadbconsumer/${SERVICE_NAME} -o yaml | shyaml get-value spec.consumer.database do if [ $OPERATOR_COUNTER -lt $OPERATOR_TIMEOUT ]; then + consumer_failed=$(kubectl -n ${NAMESPACE} get mariadbconsumer/${SERVICE_NAME} -o json | jq -r '.metadata.annotations."dbaas.amazee.io/failed"') + if [ "${consumer_failed}" == "true" ]; then + echo "Failed to provision a database. Contact your support team to investigate." + exit 1 + fi let OPERATOR_COUNTER=OPERATOR_COUNTER+1 echo "Service for ${SERVICE_NAME} not available yet, waiting for 5 secs" sleep 5 diff --git a/legacy/scripts/exec-kubectl-mongodb-dbaas.sh b/legacy/scripts/exec-kubectl-mongodb-dbaas.sh index 1c5a44d7..6ccbe52e 100644 --- a/legacy/scripts/exec-kubectl-mongodb-dbaas.sh +++ b/legacy/scripts/exec-kubectl-mongodb-dbaas.sh @@ -1,13 +1,18 @@ #!/bin/bash # The operator can sometimes take a bit, wait until the details are available -# We added a timeout of 10 minutes (120 retries) before exit +# We added a timeout of 5 minutes (60 retries) before exit OPERATOR_COUNTER=1 -OPERATOR_TIMEOUT=180 +OPERATOR_TIMEOUT=60 # use the secret name from the consumer to prevent credential clash until kubectl -n ${NAMESPACE} get mongodbconsumer/${SERVICE_NAME} -o yaml | shyaml get-value spec.consumer.database do if [ $OPERATOR_COUNTER -lt $OPERATOR_TIMEOUT ]; then + consumer_failed=$(kubectl -n ${NAMESPACE} get mongodbconsumer/${SERVICE_NAME} -o json | jq -r '.metadata.annotations."dbaas.amazee.io/failed"') + if [ "${consumer_failed}" == "true" ]; then + echo "Failed to provision a database. Contact your support team to investigate." + exit 1 + fi let OPERATOR_COUNTER=OPERATOR_COUNTER+1 echo "Service for ${SERVICE_NAME} not available yet, waiting for 5 secs" sleep 5 diff --git a/legacy/scripts/exec-kubectl-postgres-dbaas.sh b/legacy/scripts/exec-kubectl-postgres-dbaas.sh index 5c19bf3b..ba3f9372 100644 --- a/legacy/scripts/exec-kubectl-postgres-dbaas.sh +++ b/legacy/scripts/exec-kubectl-postgres-dbaas.sh @@ -1,13 +1,18 @@ #!/bin/bash # The operator can sometimes take a bit, wait until the details are available -# We added a timeout of 10 minutes (120 retries) before exit +# We added a timeout of 5 minutes (60 retries) before exit OPERATOR_COUNTER=1 -OPERATOR_TIMEOUT=180 +OPERATOR_TIMEOUT=60 # use the secret name from the consumer to prevent credential clash until kubectl -n ${NAMESPACE} get postgresqlconsumer/${SERVICE_NAME} -o yaml | shyaml get-value spec.consumer.database do if [ $OPERATOR_COUNTER -lt $OPERATOR_TIMEOUT ]; then + consumer_failed=$(kubectl -n ${NAMESPACE} get postgresqlconsumer/${SERVICE_NAME} -o json | jq -r '.metadata.annotations."dbaas.amazee.io/failed"') + if [ "${consumer_failed}" == "true" ]; then + echo "Failed to provision a database. Contact your support team to investigate." + exit 1 + fi let OPERATOR_COUNTER=OPERATOR_COUNTER+1 echo "Service for ${SERVICE_NAME} not available yet, waiting for 5 secs" sleep 5