custom alerting resolve conflicts
Signed-off-by: junotx <junotx@126.com>
This commit is contained in:
@@ -5,10 +5,10 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
promresourcesv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
|
||||
prominformersv1 "github.com/prometheus-operator/prometheus-operator/pkg/client/informers/externalversions/monitoring/v1"
|
||||
promresourcesclient "github.com/prometheus-operator/prometheus-operator/pkg/client/versioned"
|
||||
"github.com/pkg/errors"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
|
||||
@@ -23,6 +23,7 @@ func NewRuleCache(ruleResourceInformer prominformersv1.PrometheusRuleInformer) *
|
||||
rc := RuleCache{
|
||||
namespaces: make(map[string]*namespaceRuleCache),
|
||||
}
|
||||
|
||||
ruleResourceInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
|
||||
AddFunc: rc.addCache,
|
||||
UpdateFunc: func(oldObj, newObj interface{}) {
|
||||
|
||||
@@ -22,7 +22,7 @@ const (
|
||||
|
||||
var (
|
||||
maxSecretSize = corev1.MaxSecretSize
|
||||
maxConfigMapDataSize = int(float64(maxSecretSize) * 0.3)
|
||||
maxConfigMapDataSize = int(float64(maxSecretSize) * 0.45)
|
||||
|
||||
errOutOfConfigMapSize = errors.New("out of config map size")
|
||||
)
|
||||
@@ -124,7 +124,7 @@ func (r *ruleResource) updateAlertingRule(groupName string, rule *promresourcesv
|
||||
}
|
||||
|
||||
npr.Spec.Groups = groups
|
||||
content, err := yaml.Marshal(npr)
|
||||
content, err := yaml.Marshal(npr.Spec)
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, "failed to unmarshal content")
|
||||
}
|
||||
@@ -160,7 +160,7 @@ func (r *ruleResource) addAlertingRule(group string, rule *promresourcesv1.Rule)
|
||||
})
|
||||
}
|
||||
|
||||
content, err := yaml.Marshal(npr)
|
||||
content, err := yaml.Marshal(npr.Spec)
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, "failed to unmarshal content")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user