diff options
author | Kyle Wiebers <kwiebers@gitlab.com> | 2019-09-09 14:29:44 -0500 |
---|---|---|
committer | Kyle Wiebers <kwiebers@gitlab.com> | 2019-09-10 10:56:52 -0500 |
commit | 5a1659d884ff2e5b71b86cca4203245ac098c41b (patch) | |
tree | 0379680c6ca78e8818b8a34f4ae1b136b103da6b | |
parent | 7e8453fe926325ccffbadb509c59b8a5e1867886 (diff) | |
download | gitlab-ce-5a1659d884ff2e5b71b86cca4203245ac098c41b.tar.gz |
Add review-cleanup-failed-deployment to prepareadd-review-app-cleanup
Add in a job to purge previous release in Review App
-rw-r--r-- | .gitlab/ci/review.gitlab-ci.yml | 9 | ||||
-rwxr-xr-x | scripts/review_apps/review-apps.sh | 21 |
2 files changed, 29 insertions, 1 deletions
diff --git a/.gitlab/ci/review.gitlab-ci.yml b/.gitlab/ci/review.gitlab-ci.yml index 6f1505b5c0d..8e612243371 100644 --- a/.gitlab/ci/review.gitlab-ci.yml +++ b/.gitlab/ci/review.gitlab-ci.yml @@ -134,6 +134,15 @@ review-stop: artifacts: paths: [] +review-cleanup-failed-deployment: + extends: review-stop + stage: prepare + when: on_success + needs: [] + allow_failure: false + script: + - delete_failed_release + .review-qa-base: extends: - .review-docker diff --git a/scripts/review_apps/review-apps.sh b/scripts/review_apps/review-apps.sh index a9549171b54..b95bc4e743e 100755 --- a/scripts/review_apps/review-apps.sh +++ b/scripts/review_apps/review-apps.sh @@ -49,6 +49,26 @@ function delete_release() { helm delete --purge "$name" } +function delete_failed_release() { + if [ -z "$CI_ENVIRONMENT_SLUG" ]; then + echoerr "No release given, aborting the delete!" + return + fi + + if ! deploy_exists "${KUBE_NAMESPACE}" "${CI_ENVIRONMENT_SLUG}"; then + echoinfo "No Review App with ${CI_ENVIRONMENT_SLUG} is currently deployed." + else + # Cleanup and previous installs, as FAILED and PENDING_UPGRADE will cause errors with `upgrade` + if previous_deploy_failed "$CI_ENVIRONMENT_SLUG" ; then + echoinfo "Review App deployment in bad state, cleaning up $CI_ENVIRONMENT_SLUG" + delete_release + else + echoinfo "Review App deployment in good state" + fi + fi +} + + function get_pod() { local app_name="${1}" local status="${2-Running}" @@ -193,7 +213,6 @@ function deploy() { HELM_CMD=$(cat << EOF helm upgrade --install \ - --force \ --wait \ --timeout 900 \ --set releaseOverride="$CI_ENVIRONMENT_SLUG" \ |