From 24e7f114890ad04ce645215789a64515c753effb Mon Sep 17 00:00:00 2001 From: junot <49136171+junotx@users.noreply.github.com> Date: Wed, 1 Mar 2023 20:22:37 +0800 Subject: [PATCH] fix rulegroups to prometheusrules (#5561) Signed-off-by: junot --- pkg/controller/alerting/util.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/controller/alerting/util.go b/pkg/controller/alerting/util.go index cef6fd37c..7f14d4750 100644 --- a/pkg/controller/alerting/util.go +++ b/pkg/controller/alerting/util.go @@ -326,7 +326,7 @@ func makePrometheusRuleSpecs(rulegroups []*promresourcesv1.RuleGroup) ([]*promre var ( pSpecs []*promresourcesv1.PrometheusRuleSpec - pSpec promresourcesv1.PrometheusRuleSpec + pSpec = &promresourcesv1.PrometheusRuleSpec{} size int ) @@ -340,16 +340,16 @@ func makePrometheusRuleSpecs(rulegroups []*promresourcesv1.RuleGroup) ([]*promre contentLen := len(string(content)) size += contentLen if size > maxConfigMapDataSize*80/100 { // leave space for enforcing possiable label matchers into expr - pSpecs = append(pSpecs, &pSpec) + pSpecs = append(pSpecs, pSpec) // reinit size = contentLen - pSpec = promresourcesv1.PrometheusRuleSpec{} + pSpec = &promresourcesv1.PrometheusRuleSpec{} } pSpec.Groups = append(pSpec.Groups, *rulegroup) } if len(pSpec.Groups) > 0 { - pSpecs = append(pSpecs, &pSpec) + pSpecs = append(pSpecs, pSpec) } return pSpecs, nil