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

Handle `Gitlab::Error::Forbidden`

parent 5fad8112
......@@ -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
......
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