Skip to content

Commit 61d7855

Browse files
committed
fix(RulerAction): Fixed logic for events
1 parent 2c9c8e9 commit 61d7855

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ Here’s an example to show how to configure an Alertmanager-compatible message:
288288
{{- $description := printf `
289289

290290
Description: %s
291-
Value: %s
291+
Value: %v
292292

293293
-------------------------------
294294
Name: %s

internal/controller/ruleraction_controller.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,17 @@ func (r *RulerActionReconciler) Reconcile(ctx context.Context, req ctrl.Request)
5858

5959
// 1. Get the content of the Patch
6060

61-
// 1.1 Try with RulerAction resource first. If it is not a RulerAction, then it will return an error
62-
// but reconcile will try if it is an Event resource relationated with a RulerAction
61+
// 1.1 Try with Event resource first. If it is not an Event, then it will return an error
62+
// but reconcile will try if it is a RulerAction resource relationated with an Event
6363
RulerActionResource := &searchrulerv1alpha1.RulerAction{}
64-
err = r.Get(ctx, req.NamespacedName, RulerActionResource)
65-
if err != nil {
66-
// 1.2 Try with Event resource, if the event is not relationated with a RulerAction, then it will return an error
67-
// but if true, the program goes to processEvent label, so events do not need to execute the rest of the code
68-
*RulerActionResource, err = r.GetEventRuleAction(ctx, req.Namespace, req.Name)
69-
if err != nil {
70-
return result, fmt.Errorf(GetRulerActionErrorMessage, err.Error())
71-
}
72-
// Go to processEvent Label in step 7 (Sync function)
64+
*RulerActionResource, err = r.GetEventRuleAction(ctx, req.Namespace, req.Name)
65+
if err == nil {
7366
goto processEvent
7467
}
7568

69+
// 1.2 Try with RulerAction resource
70+
err = r.Get(ctx, req.NamespacedName, RulerActionResource)
71+
7672
// 2. Check existence on the cluster
7773
if err != nil {
7874

0 commit comments

Comments
 (0)