Commit be9a53ac authored by Albert Salim's avatar Albert Salim

Stop environment before deleting

Attempting to delete an environment
that has not been stopped yet
would lead to a forbidden error.
parent e365bb9a
......@@ -115,14 +115,16 @@ class AutomatedCleanup
last_deploy = deployment.created_at
deployed_at = Time.parse(last_deploy)
if deployed_at < stop_threshold
environment_state = fetch_environment(environment)&.state
stop_environment(environment, deployment) if environment_state && environment_state != 'stopped'
end
if deployed_at < delete_threshold
delete_environment(environment, deployment)
delete_count += 1
break if delete_count > max_delete_count
elsif deployed_at < stop_threshold
environment_state = fetch_environment(environment)&.state
stop_environment(environment, deployment) if environment_state && environment_state != 'stopped'
end
checked_environments << environment.slug
......
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