Commit 96195d4f authored by Albert Salim's avatar Albert Salim

Handle `Gitlab::Error::Forbidden`

parent 5fad8112
...@@ -75,9 +75,11 @@ class AutomatedCleanup ...@@ -75,9 +75,11 @@ class AutomatedCleanup
deployed_at = Time.parse(last_deploy) deployed_at = Time.parse(last_deploy)
if deployed_at < delete_threshold if deployed_at < delete_threshold
delete_environment(environment, deployment) environment = delete_environment(environment, deployment)
release = Quality::HelmClient::Release.new(environment.slug, 1, deployed_at.to_s, nil, nil, review_apps_namespace) if environment
releases_to_delete << release 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 elsif deployed_at < stop_threshold
stop_environment(environment, deployment) stop_environment(environment, deployment)
else else
...@@ -116,11 +118,17 @@ class AutomatedCleanup ...@@ -116,11 +118,17 @@ class AutomatedCleanup
def delete_environment(environment, deployment) def delete_environment(environment, deployment)
print_release_state(subject: 'Review app', release_name: environment.slug, release_date: deployment.created_at, action: 'deleting') print_release_state(subject: 'Review app', release_name: environment.slug, release_date: deployment.created_at, action: 'deleting')
gitlab.delete_environment(project_path, environment.id) gitlab.delete_environment(project_path, environment.id)
rescue Gitlab::Error::Forbidden
puts "Review app '#{environment.slug}' is forbidden: skipping it"
end end
def stop_environment(environment, deployment) def stop_environment(environment, deployment)
print_release_state(subject: 'Review app', release_name: environment.slug, release_date: deployment.created_at, action: 'stopping') print_release_state(subject: 'Review app', release_name: environment.slug, release_date: deployment.created_at, action: 'stopping')
gitlab.stop_environment(project_path, environment.id) gitlab.stop_environment(project_path, environment.id)
rescue Gitlab::Error::Forbidden
puts "Review app '#{environment.slug}' is forbidden: skipping it"
end end
def helm_releases def helm_releases
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment