danielmeint commented on code in PR #880:
URL: https://github.com/apache/solr-operator/pull/880#discussion_r4550439680
##########
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:
fyi, Solr 9.7+ also serves Prometheus format with `wt=prometheus`, so you
could make that the cutoff, although it would require a minor-aware version
check I guess
--
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]