diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-14 03:09:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-14 03:09:07 +0300 |
commit | e144369009f3404072f7e0f969f7cded93195a01 (patch) | |
tree | d7a354e2c3c69a7ad65dc81aba8fe2ba59b0a26f /app/services/ci | |
parent | d466ee5042520ad078fe050cb078d81dc2ebe196 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/ci')
-rw-r--r-- | app/services/ci/stop_environments_service.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/app/services/ci/stop_environments_service.rb b/app/services/ci/stop_environments_service.rb index d9a800791f2..14ef744ada1 100644 --- a/app/services/ci/stop_environments_service.rb +++ b/app/services/ci/stop_environments_service.rb @@ -16,6 +16,22 @@ module Ci merge_request.environments.each { |environment| stop(environment) } end + ## + # This method is for stopping multiple environments in a batch style. + # The maximum acceptable count of environments is roughly 5000. Please + # apply acceptable `LIMIT` clause to the `environments` relation. + def self.execute_in_batch(environments) + stop_actions = environments.stop_actions.load + + environments.update_all(auto_stop_at: nil, state: 'stopped') + + stop_actions.each do |stop_action| + stop_action.play(stop_action.user) + rescue => e + Gitlab::ErrorTracking.track_error(e, deployable_id: stop_action.id) + end + end + private def environments |