Skip to content

Commit

Permalink
Log warning and create event
Browse files Browse the repository at this point in the history
  • Loading branch information
bmangoen committed Jul 3, 2023
1 parent c5a9252 commit 6ca00aa
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkg/controller/servicemesh/webhooks/hacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,18 @@ func createWebhookResources(ctx context.Context, mgr manager.Manager, log logr.L

log.Info("Creating Maistra Operator webhook PrometheusRule")
monclient, _ := clientmonitoring.NewForConfig(mgr.GetConfig())
prometheusRule := newPrometheusRule(operatorNamespace,
"maistra-operator-prometheusrule",
"sum without (smcp_namespace) (servicemesh_members)",
"cluster:servicemesh_members:sum")
if _, err := monclient.PrometheusRules(operatorNamespace).Create(context.TODO(),
newPrometheusRule(operatorNamespace,
"maistra-operator-prometheusrule",
"sum without (smcp_namespace) (servicemesh_members)",
"cluster:servicemesh_members:sum"), metav1.CreateOptions{}); err != nil {
prometheusRule, metav1.CreateOptions{}); err != nil {
if errors.IsAlreadyExists(err) {
log.Info("Maistra Operator webhook PrometheusRule already exists")
} else {
return pkgerrors.Wrap(err, "error creating Maistra Operator webhook PrometheusRule")
log.Error(err, "warning: failed to create Maistra Operator webhook PrometheusRule")
mgr.GetEventRecorderFor("maistra-operator-prometheusrule-webhook").Event(prometheusRule,
"Warning", "Failed", "Failed to create Maistra Operator webhook PrometheusRule")
}
}

Expand Down

0 comments on commit 6ca00aa

Please sign in to comment.