Skip to content

Add group web-hooks failed notifications

Alex Kalderimis requested to merge 385902-ajk-grps-whs into master

What does this MR do and why?

Adds callouts that are shown if any web-hook in a group has failed.

Screenshot

1675798386

How to set up and validate locally

Because we are adding notifications before we add the ability for group-hooks to be disabled, testing is a little more involved.

To test, you need to apply the following patch:

diff --git a/ee/app/helpers/ee/web_hooks/web_hooks_helper.rb b/ee/app/helpers/ee/web_hooks/web_hooks_helper.rb
index ab55cf18ef20..5e4ca9a5a92d 100644
--- a/ee/app/helpers/ee/web_hooks/web_hooks_helper.rb
+++ b/ee/app/helpers/ee/web_hooks/web_hooks_helper.rb
@@ -22,9 +22,10 @@ def group_hook_page?
       end
 
       def any_group_hook_failed?(group)
-        any_hook_failed?("any_web_hook_failed:group:#{group.id}") do
+        # Disabled so that we don't have to wait for the cache to expire
+        # any_hook_failed?("any_web_hook_failed:group:#{group.id}") do
           group.any_web_hook_failed?
-        end
+        # end
       end
     end
   end
diff --git a/ee/app/models/ee/group.rb b/ee/app/models/ee/group.rb
index 2d530e922446..5ef74c9e4e2d 100644
--- a/ee/app/models/ee/group.rb
+++ b/ee/app/models/ee/group.rb
@@ -653,13 +653,6 @@ def execute_hooks(data, hooks_scope)
       end
     end
 
-    override :any_web_hook_failed?
-    def any_web_hook_failed?
-      # morally `hooks.disabled.exists?`, but since group hooks include
-      # Unstoppable, we simply return `false`.
-      false
-    end
-
     override :git_transfer_in_progress?
     def git_transfer_in_progress?
       reference_counter(type: ::Gitlab::GlRepository::WIKI).value > 0
diff --git a/ee/app/models/hooks/group_hook.rb b/ee/app/models/hooks/group_hook.rb
index de3a967ee16a..c41e1ac85109 100644
--- a/ee/app/models/hooks/group_hook.rb
+++ b/ee/app/models/hooks/group_hook.rb
@@ -3,7 +3,7 @@
 class GroupHook < WebHook
   include CustomModelNaming
   include TriggerableHooks
-  include WebHooks::Unstoppable
+  include WebHooks::AutoDisabling
   include Presentable
   include Limitable
   extend ::Gitlab::Utils::Override

Which will enable the automatic disabling of group hooks.

Then you can proceed with manual testing as per project hooks:

  1. Set up a (failing) group hook
  2. Trigger it twice, see that it fails
  3. Trigger it twice more, then visit any group page (for that group)

You should see a banner at the top announcing that the hook has failed (see screenshots)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

related issue: #385902 (closed)

Edited by Alex Kalderimis

Merge request reports