diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /app/models/hooks | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'app/models/hooks')
-rw-r--r-- | app/models/hooks/web_hook.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/app/models/hooks/web_hook.rb b/app/models/hooks/web_hook.rb index 5f8fa4bca0a..9a78fe3971c 100644 --- a/app/models/hooks/web_hook.rb +++ b/app/models/hooks/web_hook.rb @@ -69,21 +69,26 @@ class WebHook < ApplicationRecord end def disable! - update!(recent_failures: FAILURE_THRESHOLD + 1) + update_attribute(:recent_failures, FAILURE_THRESHOLD + 1) end def enable! return if recent_failures == 0 && disabled_until.nil? && backoff_count == 0 - update!(recent_failures: 0, disabled_until: nil, backoff_count: 0) + assign_attributes(recent_failures: 0, disabled_until: nil, backoff_count: 0) + save(validate: false) end def backoff! - update!(disabled_until: next_backoff.from_now, backoff_count: backoff_count.succ.clamp(0, MAX_FAILURES)) + assign_attributes(disabled_until: next_backoff.from_now, backoff_count: backoff_count.succ.clamp(0, MAX_FAILURES)) + save(validate: false) end def failed! - update!(recent_failures: recent_failures + 1) if recent_failures < MAX_FAILURES + return unless recent_failures < MAX_FAILURES + + assign_attributes(recent_failures: recent_failures + 1) + save(validate: false) end # Overridden in ProjectHook and GroupHook, other webhooks are not rate-limited. |