Skip to content

Commit

Permalink
Watch CMO cluster monitoring ConfigMap for changes (#1549)
Browse files Browse the repository at this point in the history
Signed-off-by: Philip Gough <[email protected]>
  • Loading branch information
philipgough authored Jul 30, 2024
1 parent e00c695 commit 75cb1c2
Showing 1 changed file with 37 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -540,51 +540,63 @@ func (r *ObservabilityAddonReconciler) SetupWithManager(mgr ctrl.Manager) error
builder.WithPredicates(getPred(openshift.CaConfigmapName, r.Namespace, false, true, true)),
).
Watches(
&appsv1.Deployment{},
&corev1.ConfigMap{},
&handler.EnqueueRequestForObject{},
builder.WithPredicates(getPred(metricsCollectorName, r.Namespace, true, true, true)),
builder.WithPredicates(getPred(operatorconfig.ImageConfigMap, r.Namespace, true, true, false)),
).
Watches(
&appsv1.Deployment{},
&corev1.ConfigMap{},
enqueueForAPIServerAuth(r.Namespace),
builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}),
).
Watches(
&corev1.ConfigMap{},
&handler.EnqueueRequestForObject{},
builder.WithPredicates(getPred(uwlMetricsCollectorName, r.Namespace, true, true, true)),
builder.WithPredicates(getPred(clusterMonitoringConfigName, promNamespace, true, true, false)),
).
Watches(
&rbacv1.ClusterRoleBinding{},
&appsv1.Deployment{},
&handler.EnqueueRequestForObject{},
builder.WithPredicates(getPred(openshift.ClusterRoleBindingName, "", false, true, true)),
builder.WithPredicates(getPred(metricsCollectorName, r.Namespace, true, true, true)),
).
Watches(
&corev1.ConfigMap{},
&appsv1.Deployment{},
&handler.EnqueueRequestForObject{},
builder.WithPredicates(getPred(operatorconfig.ImageConfigMap, r.Namespace, true, true, false)),
builder.WithPredicates(getPred(uwlMetricsCollectorName, r.Namespace, true, true, true)),
).
Watches(
&appsv1.StatefulSet{},
&handler.EnqueueRequestForObject{},
builder.WithPredicates(getPred(operatorconfig.PrometheusUserWorkload, uwlNamespace, true, false, true)),
).
// Watch the kube-system extension-apiserver-authentication ConfigMap for changes
Watches(&corev1.ConfigMap{}, handler.EnqueueRequestsFromMapFunc(
func(ctx context.Context, a client.Object) []reconcile.Request {
if a.GetName() == "extension-apiserver-authentication" && a.GetNamespace() == "kube-system" {
return []reconcile.Request{
{NamespacedName: types.NamespacedName{
Name: "metrics-collector-clientca-metric",
Namespace: r.Namespace,
}},
{NamespacedName: types.NamespacedName{
Name: "uwl-metrics-collector-clientca-metric",
Namespace: r.Namespace,
}},
}
}
return nil
}), builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}),
Watches(
&rbacv1.ClusterRoleBinding{},
&handler.EnqueueRequestForObject{},
builder.WithPredicates(getPred(openshift.ClusterRoleBindingName, "", false, true, true)),
).
Complete(r)
}

// Watch the kube-system extension-apiserver-authentication ConfigMap for changes
func enqueueForAPIServerAuth(namespace string) handler.EventHandler {
return handler.EnqueueRequestsFromMapFunc(
func(ctx context.Context, a client.Object) []reconcile.Request {
if a.GetName() == "extension-apiserver-authentication" && a.GetNamespace() == "kube-system" {
return []reconcile.Request{
{NamespacedName: types.NamespacedName{
Name: "metrics-collector-clientca-metric",
Namespace: namespace,
}},
{NamespacedName: types.NamespacedName{
Name: "uwl-metrics-collector-clientca-metric",
Namespace: namespace,
}},
}
}
return nil
})
}

func remove(list []string, s string) []string {
result := []string{}
for _, v := range list {
Expand Down

0 comments on commit 75cb1c2

Please sign in to comment.