Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

monitoring: update label on prometheus resources #9243

Merged
merged 1 commit into from Nov 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/operator/k8sutil/prometheus.go
Expand Up @@ -80,6 +80,7 @@ func CreateOrUpdateServiceMonitor(serviceMonitorDefinition *monitoringv1.Service
return nil, fmt.Errorf("failed to retrieve servicemonitor. %v", err)
}
oldSm.Spec = serviceMonitorDefinition.Spec
oldSm.ObjectMeta.Labels = serviceMonitorDefinition.ObjectMeta.Labels
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to do the same for annotations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually had that in there at first, but iirc there is currently no way to set annotations on these resources via rook CRDs and the templates do not contain any, too - so I removed that, for not cluttering code with seemingly unneeded things.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, we should probably add the annotations in a future PR, but looks good for now!

sm, err := client.MonitoringV1().ServiceMonitors(namespace).Update(ctx, oldSm, metav1.UpdateOptions{})
if err != nil {
return nil, fmt.Errorf("failed to update servicemonitor. %v", err)
Expand Down Expand Up @@ -123,6 +124,7 @@ func CreateOrUpdatePrometheusRule(prometheusRule *monitoringv1.PrometheusRule) (
return nil, fmt.Errorf("failed to get prometheusRule object. %v", err)
}
promRule.Spec = prometheusRule.Spec
promRule.ObjectMeta.Labels = prometheusRule.ObjectMeta.Labels
_, err = client.MonitoringV1().PrometheusRules(namespace).Update(ctx, promRule, metav1.UpdateOptions{})
if err != nil {
return nil, fmt.Errorf("failed to update prometheusRule. %v", err)
Expand Down