Skip to content

Commit

Permalink
[FIX] empty rule group (#118)
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Takashi <nicolas.takashi@coralogix.com>
  • Loading branch information
nicolastakashi authored Jul 29, 2024
1 parent d832ea1 commit 81b7d8c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions controllers/prometheusrule_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ func (r *PrometheusRuleReconciler) convertPrometheusRuleRecordingRuleToCxRecordi
return fmt.Errorf("received an error while trying to get RecordingRuleGroupSet CRD: %w", err)
}

recordingRuleGroupSet.Spec = recordingRuleGroupSetSpec
if err := r.Client.Update(ctx, recordingRuleGroupSet); err != nil {
return fmt.Errorf("received an error while trying to update RecordingRuleGroupSet CRD: %w", err)
}
Expand Down Expand Up @@ -212,11 +213,13 @@ func prometheusRuleToRecordingRuleToRuleGroupSet(log logr.Logger, prometheusRule
interval = int32(duration.Seconds())
}

groups = append(groups, coralogixv1alpha1.RecordingRuleGroup{
Name: group.Name,
IntervalSeconds: interval,
Rules: prometheusInnerRulesToCoralogixInnerRules(group.Rules),
})
if rules := prometheusInnerRulesToCoralogixInnerRules(group.Rules); len(rules) > 0 {
groups = append(groups, coralogixv1alpha1.RecordingRuleGroup{
Name: group.Name,
IntervalSeconds: interval,
Rules: rules,
})
}
}

return coralogixv1alpha1.RecordingRuleGroupSetSpec{
Expand Down

0 comments on commit 81b7d8c

Please sign in to comment.