Skip to content

Commit

Permalink
fix(RulerAction): Fixed logic for events
Browse files Browse the repository at this point in the history
  • Loading branch information
dfradehubs committed Dec 4, 2024
1 parent 2c9c8e9 commit 61d7855
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ Here’s an example to show how to configure an Alertmanager-compatible message:
{{- $description := printf `

Description: %s
Value: %s
Value: %v

-------------------------------
Name: %s
Expand Down
18 changes: 7 additions & 11 deletions internal/controller/ruleraction_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,17 @@ func (r *RulerActionReconciler) Reconcile(ctx context.Context, req ctrl.Request)

// 1. Get the content of the Patch

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

// 1.2 Try with RulerAction resource
err = r.Get(ctx, req.NamespacedName, RulerActionResource)

// 2. Check existence on the cluster
if err != nil {

Expand Down

0 comments on commit 61d7855

Please sign in to comment.