summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2019-04-18 16:05:21 +0200
committerRémy Coutable <remy@rymai.me>2019-04-19 10:50:43 +0200
commitd0efb430ce43953d659b1f62bf58a9ac41804bc3 (patch)
tree28ab2f96f6cf2b7899d644afdff912f37e24f1d5
parent5572b168e6bf59725f84b28820fcfdc81d3ac7e8 (diff)
downloadgitlab-ce-retry-review-deploy-twice.tar.gz
Make the Review App cleanup more efficientretry-review-deploy-twice
Ensure that the cleanup starts right away. Signed-off-by: Rémy Coutable <remy@rymai.me>
-rw-r--r--.gitlab/ci/review.gitlab-ci.yml2
-rw-r--r--lib/quality/kubernetes_client.rb2
-rwxr-xr-xscripts/review_apps/review-apps.sh6
-rw-r--r--spec/lib/quality/kubernetes_client_spec.rb4
4 files changed, 8 insertions, 6 deletions
diff --git a/.gitlab/ci/review.gitlab-ci.yml b/.gitlab/ci/review.gitlab-ci.yml
index 5ecd50bf903..9cfb50eeefc 100644
--- a/.gitlab/ci/review.gitlab-ci.yml
+++ b/.gitlab/ci/review.gitlab-ci.yml
@@ -32,7 +32,6 @@
environment: &review-environment
name: review/${CI_COMMIT_REF_NAME}
url: https://gitlab-${CI_ENVIRONMENT_SLUG}.${REVIEW_APPS_DOMAIN}
- before_script: []
.review-docker: &review-docker
<<: *review-base
@@ -48,6 +47,7 @@
DOCKER_HOST: tcp://docker:2375
LATEST_QA_IMAGE: "gitlab/${CI_PROJECT_NAME}-qa:nightly"
QA_IMAGE: "${CI_REGISTRY}/${CI_PROJECT_PATH}/gitlab/${CI_PROJECT_NAME}-qa:${CI_COMMIT_REF_SLUG}"
+ before_script: []
build-qa-image:
<<: *review-docker
diff --git a/lib/quality/kubernetes_client.rb b/lib/quality/kubernetes_client.rb
index 2ff9e811425..190b48ba7cb 100644
--- a/lib/quality/kubernetes_client.rb
+++ b/lib/quality/kubernetes_client.rb
@@ -18,6 +18,8 @@ module Quality
'delete',
'ingress,svc,pdb,hpa,deploy,statefulset,job,pod,secret,configmap,pvc,secret,clusterrole,clusterrolebinding,role,rolebinding,sa',
'--now',
+ '--ignore-not-found',
+ '--include-uninitialized',
%(-l release="#{release_name}")
]
diff --git a/scripts/review_apps/review-apps.sh b/scripts/review_apps/review-apps.sh
index 51cfd145ba8..b55ce1af55e 100755
--- a/scripts/review_apps/review-apps.sh
+++ b/scripts/review_apps/review-apps.sh
@@ -68,7 +68,7 @@ function delete() {
echoinfo "Deleting release '$name'..." true
- helm delete --purge "$name" || true
+ helm delete --purge "$name"
}
function cleanup() {
@@ -81,8 +81,8 @@ function cleanup() {
kubectl -n "$KUBE_NAMESPACE" delete \
ingress,svc,pdb,hpa,deploy,statefulset,job,pod,secret,configmap,pvc,secret,clusterrole,clusterrolebinding,role,rolebinding,sa \
- -l release="$CI_ENVIRONMENT_SLUG" \
- || true
+ --now --ignore-not-found --include-uninitialized \
+ -l release="$CI_ENVIRONMENT_SLUG"
}
function get_pod() {
diff --git a/spec/lib/quality/kubernetes_client_spec.rb b/spec/lib/quality/kubernetes_client_spec.rb
index f35d9464d48..4e77dcc97e6 100644
--- a/spec/lib/quality/kubernetes_client_spec.rb
+++ b/spec/lib/quality/kubernetes_client_spec.rb
@@ -13,7 +13,7 @@ RSpec.describe Quality::KubernetesClient do
expect(Gitlab::Popen).to receive(:popen_with_detail)
.with([%(kubectl --namespace "#{namespace}" delete ) \
'ingress,svc,pdb,hpa,deploy,statefulset,job,pod,secret,configmap,pvc,secret,clusterrole,clusterrolebinding,role,rolebinding,sa ' \
- "--now -l release=\"#{release_name}\""])
+ "--now --ignore-not-found --include-uninitialized -l release=\"#{release_name}\""])
.and_return(Gitlab::Popen::Result.new([], '', '', double(success?: false)))
expect { subject.cleanup(release_name: release_name) }.to raise_error(described_class::CommandFailedError)
@@ -23,7 +23,7 @@ RSpec.describe Quality::KubernetesClient do
expect(Gitlab::Popen).to receive(:popen_with_detail)
.with([%(kubectl --namespace "#{namespace}" delete ) \
'ingress,svc,pdb,hpa,deploy,statefulset,job,pod,secret,configmap,pvc,secret,clusterrole,clusterrolebinding,role,rolebinding,sa ' \
- "--now -l release=\"#{release_name}\""])
+ "--now --ignore-not-found --include-uninitialized -l release=\"#{release_name}\""])
.and_return(Gitlab::Popen::Result.new([], '', '', double(success?: true)))
# We're not verifying the output here, just silencing it