Skip to content

Commit

Permalink
fix(ratiorule): null sli spec validation
Browse files Browse the repository at this point in the history
Signed-off-by: Hy3n4 <hy3nk4@gmail.com>
  • Loading branch information
Hy3n4 committed Nov 14, 2023
1 parent 4308f94 commit 4cfae49
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/utils/common_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,19 @@ func (c RuleConfig) NewRatioRule(window string) (*monitoringv1.Rule, *monitoring

switch c.RuleType {
case "total":
if c.Sli.Spec.RatioMetric.Total.MetricSource.Spec == "" {
return nil, nil
}
expr = fmt.Sprintf("sum(increase(%s[%s]))", c.Sli.Spec.RatioMetric.Total.MetricSource.Spec, window)
case "bad":
if c.Sli.Spec.RatioMetric.Bad.MetricSource.Spec == "" {
return nil, nil
}
expr = fmt.Sprintf("sum(increase(%s[%s]))", c.Sli.Spec.RatioMetric.Bad.MetricSource.Spec, window)
case "good":
if c.Sli.Spec.RatioMetric.Good.MetricSource.Spec == "" {
return nil, nil
}
expr = fmt.Sprintf("sum(increase(%s[%s]))", c.Sli.Spec.RatioMetric.Good.MetricSource.Spec, window)
}

Expand Down

0 comments on commit 4cfae49

Please sign in to comment.