Copilot commented on code in PR #880:
URL: https://github.com/apache/solr-operator/pull/880#discussion_r4573544490
##########
controllers/util/common.go:
##########
@@ -199,6 +200,21 @@ func CopyConfigMapFields(from, to *corev1.ConfigMap,
logger logr.Logger) bool {
return requireUpdate
}
+// CopyPodMonitorFields copies the owned fields from one PodMonitor to another
+func CopyPodMonitorFields(from, to *monitoringv1.PodMonitor, logger
logr.Logger) bool {
+ logger = logger.WithValues("kind", "podMonitor")
+ requireUpdate := CopyLabelsAndAnnotations(&from.ObjectMeta,
&to.ObjectMeta, logger)
Review Comment:
Adding an empty-valued label to an existing PodMonitor is silently ignored
because `CopyLabelsAndAnnotations` treats an absent key as equal to `""`. Empty
label values are valid, so a Prometheus selecting `matchLabels: {scrape: ""}`
will not discover the PodMonitor after `labels: {scrape: ""}` is configured.
Treat missing label keys as changes as well.
##########
controllers/util/common.go:
##########
@@ -199,6 +200,21 @@ func CopyConfigMapFields(from, to *corev1.ConfigMap,
logger logr.Logger) bool {
return requireUpdate
}
+// CopyPodMonitorFields copies the owned fields from one PodMonitor to another
+func CopyPodMonitorFields(from, to *monitoringv1.PodMonitor, logger
logr.Logger) bool {
+ logger = logger.WithValues("kind", "podMonitor")
+ requireUpdate := CopyLabelsAndAnnotations(&from.ObjectMeta,
&to.ObjectMeta, logger)
Review Comment:
`CopyLabelsAndAnnotations` only adds or updates keys, so removing a label
from `spec.prometheus.podMonitor.labels` never removes it from the existing
PodMonitor. For example, removing `release: mon` leaves that Prometheus
instance selecting and scraping the cloud indefinitely, despite the updated
SolrCloud configuration. Please reconcile removal of previously managed
PodMonitor labels too, tracking owned keys if externally added labels need to
be preserved.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]