diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-08 15:20:17 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-08 15:20:17 +0300 |
commit | 6728ed6fe203d0613ee63c89a08a70fffb93405c (patch) | |
tree | 9eddfee7a854efd47d85899c1524fd4bd10ce8e4 /app/services/web_hooks | |
parent | 60028378dd5e5e7844810e4a2aa2934a58f738ca (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/web_hooks')
-rw-r--r-- | app/services/web_hooks/log_execution_service.rb | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/app/services/web_hooks/log_execution_service.rb b/app/services/web_hooks/log_execution_service.rb index 04b9ff59382..0ee7c41469f 100644 --- a/app/services/web_hooks/log_execution_service.rb +++ b/app/services/web_hooks/log_execution_service.rb @@ -12,8 +12,9 @@ module WebHooks def initialize(hook:, log_data:, response_category:) @hook = hook - @log_data = log_data + @log_data = log_data.transform_keys(&:to_sym) @response_category = response_category + @prev_state = hook.active_state(ignore_flag: true) end def execute @@ -24,7 +25,7 @@ module WebHooks private def log_execution - WebHookLog.create!(web_hook: hook, **log_data.transform_keys(&:to_sym)) + WebHookLog.create!(web_hook: hook, **log_data) end # Perform this operation within an `Gitlab::ExclusiveLease` lock to make it @@ -41,11 +42,36 @@ module WebHooks when :failed hook.failed! end + + log_state_change end rescue Gitlab::ExclusiveLeaseHelpers::FailedToObtainLockError raise if raise_lock_error? end + def log_state_change + new_state = hook.active_state(ignore_flag: true) + + return if @prev_state == new_state + + Gitlab::AuthLogger.info( + message: 'WebHook change active_state', + # identification + hook_id: hook.id, + hook_type: hook.type, + project_id: hook.project_id, + group_id: hook.group_id, + # relevant data + prev_state: @prev_state, + new_state: new_state, + duration: log_data[:execution_duration], + response_status: log_data[:response_status], + recent_hook_failures: hook.recent_failures, + # context + **Gitlab::ApplicationContext.current + ) + end + def lock_name "web_hooks:update_hook_failure_state:#{hook.id}" end |