summaryrefslogtreecommitdiff
path: root/scripts/review_apps/automated_cleanup.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-21 09:06:16 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-21 09:06:16 +0000
commita048261403ea7e12992ccffe704f0779235712d7 (patch)
tree59254549db6d39a4da824379a7bf354e7c8e7e67 /scripts/review_apps/automated_cleanup.rb
parent80e5134020483299c039114e76b734436f006c66 (diff)
downloadgitlab-ce-a048261403ea7e12992ccffe704f0779235712d7.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts/review_apps/automated_cleanup.rb')
-rwxr-xr-xscripts/review_apps/automated_cleanup.rb14
1 files changed, 11 insertions, 3 deletions
diff --git a/scripts/review_apps/automated_cleanup.rb b/scripts/review_apps/automated_cleanup.rb
index c7ab8829088..01bf149e76e 100755
--- a/scripts/review_apps/automated_cleanup.rb
+++ b/scripts/review_apps/automated_cleanup.rb
@@ -75,9 +75,11 @@ class AutomatedCleanup
deployed_at = Time.parse(last_deploy)
if deployed_at < delete_threshold
- delete_environment(environment, deployment)
- release = Quality::HelmClient::Release.new(environment.slug, 1, deployed_at.to_s, nil, nil, review_apps_namespace)
- releases_to_delete << release
+ environment = delete_environment(environment, deployment)
+ if environment
+ release = Quality::HelmClient::Release.new(environment.slug, 1, deployed_at.to_s, nil, nil, review_apps_namespace)
+ releases_to_delete << release
+ end
elsif deployed_at < stop_threshold
stop_environment(environment, deployment)
else
@@ -116,11 +118,17 @@ class AutomatedCleanup
def delete_environment(environment, deployment)
print_release_state(subject: 'Review app', release_name: environment.slug, release_date: deployment.created_at, action: 'deleting')
gitlab.delete_environment(project_path, environment.id)
+
+ rescue Gitlab::Error::Forbidden
+ puts "Review app '#{environment.slug}' is forbidden: skipping it"
end
def stop_environment(environment, deployment)
print_release_state(subject: 'Review app', release_name: environment.slug, release_date: deployment.created_at, action: 'stopping')
gitlab.stop_environment(project_path, environment.id)
+
+ rescue Gitlab::Error::Forbidden
+ puts "Review app '#{environment.slug}' is forbidden: skipping it"
end
def helm_releases