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
Conversation
Updating the promethes reources (PrometheusRule and ServiceMonitor) is done by fetching the current resource from the server and updating the spec on it. This commit makes it also apply the labels, so users can update them via rook CRDs. Closes: rook#9241 Signed-off-by: Mara Sophie Grosch <littlefox@lf-net.org>
@@ -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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
@@ -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 |
There was a problem hiding this comment.
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!
monitoring: update label on prometheus resources (backport #9243)
Description of your changes:
Updating the promethes resources (PrometheusRule and ServiceMonitor) is
done by fetching the current resource from the server and updating the
spec on it. This commit makes it also apply the labels, so users can
update them via rook CRDs.
Which issue is resolved by this Pull Request:
Resolves #9241
Checklist:
make codegen
) has been run to update object specifications, if necessary.