Commit f4d32264 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '36933-failed-scheduled-review-clean-up-job-with-403-on-gitlab-api' into 'master'

Skip restricted environments when deleting or stopping

Closes #36933

See merge request gitlab-org/gitlab!20518
parents 94969ce1 96195d4f
......@@ -75,9 +75,11 @@ class AutomatedCleanup
deployed_at = Time.parse(last_deploy)
if deployed_at < delete_threshold
delete_environment(environment, deployment)
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