diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-21 12:06:16 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-21 12:06:16 +0300 |
commit | a048261403ea7e12992ccffe704f0779235712d7 (patch) | |
tree | 59254549db6d39a4da824379a7bf354e7c8e7e67 /scripts/review_apps | |
parent | 80e5134020483299c039114e76b734436f006c66 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts/review_apps')
-rwxr-xr-x | scripts/review_apps/automated_cleanup.rb | 14 |
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 |