janhoy commented on code in PR #880:
URL: https://github.com/apache/solr-operator/pull/880#discussion_r4558572006


##########
controllers/solrcloud_controller.go:
##########
@@ -1014,6 +1038,101 @@ func (r *SolrCloudReconciler) reconcileNodeService(ctx 
context.Context, logger l
 
        return nil, ip
 }
+
+// reconcilePodMonitorBestEffort manages the PodMonitor of the cloud without 
ever failing the reconcile:
+// metrics are not worth stalling a Solr cluster over. A PodMonitor that 
cannot be managed, e.g. because
+// the API server rejects a user-given label, is reported as a warning event 
and retried later, while the
+// rest of the SolrCloud is reconciled as usual.
+func (r *SolrCloudReconciler) reconcilePodMonitorBestEffort(ctx 
context.Context, instance *solrv1beta1.SolrCloud, logger logr.Logger, 
requeueOrNot *reconcile.Result) {
+       if err := r.reconcilePodMonitor(ctx, instance, logger); err != nil {
+               logger.Error(err, "Could not reconcile the PodMonitor, 
continuing with the rest of the SolrCloud", "podMonitor", 
instance.PodMonitorName())
+               r.Recorder.Eventf(instance, corev1.EventTypeWarning, 
"PodMonitorError",
+                       "Could not reconcile PodMonitor %q, will retry: %v", 
instance.PodMonitorName(), err)
+               updateRequeueAfter(requeueOrNot, time.Second*30)
+       }
+}
+
+// reconcilePodMonitor creates, updates or deletes the PodMonitor for the 
cloud.
+func (r *SolrCloudReconciler) reconcilePodMonitor(ctx context.Context, 
instance *solrv1beta1.SolrCloud, logger logr.Logger) error {
+       if !instance.UsesPodMonitor() {
+               return r.deletePodMonitor(ctx, instance, logger)
+       }
+
+       // Keep managing the rest of the SolrCloud: metrics are not worth 
stalling a Solr cluster over.
+       if !usePrometheusCRD {
+               msg := "Cannot create a PodMonitor, as the Solr Operator is not 
configured to use the Prometheus Operator CRDs. Install the Solr Operator with 
`--prometheus-operator=true` to enable this."
+               logger.Error(nil, msg)
+               r.Recorder.Event(instance, corev1.EventTypeWarning, 
"MissingPrometheusCRD", msg)
+               return nil
+       }
+
+       // TODO: Gate this on Solr 10, once #827 has landed and the operator 
can parse the Solr version.

Review Comment:
   In theory, yes, we could offer it from 9.7. Problem is that while 9.7+ 
serves prom format, the content is very different from both solr10 and from 
what PrometheusExporter delivers too. So in my eyes it's fairly useless. Of 
course we could offer it to people if we wish, but for now I think 10.x is a 
natural cutoff. Did you have a chance to test it or review the implementation?



-- 
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]

Reply via email to