-
Notifications
You must be signed in to change notification settings - Fork 53
OCPBUGS-58102: Expose ExternalDNS operand metrics via kube-rbac-proxy sidecar #371
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ import ( | |
| appsv1 "k8s.io/api/apps/v1" | ||
| corev1 "k8s.io/api/core/v1" | ||
| "k8s.io/apimachinery/pkg/api/errors" | ||
| "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||
| "k8s.io/apimachinery/pkg/runtime" | ||
| "k8s.io/apimachinery/pkg/types" | ||
| ctrl "sigs.k8s.io/controller-runtime" | ||
|
|
@@ -102,6 +103,16 @@ func New(mgr manager.Manager, cfg Config) (controller.Controller, error) { | |
| return nil, err | ||
| } | ||
|
|
||
| if err := c.Watch(source.Kind[client.Object](operatorCache, &corev1.Service{}, handler.EnqueueRequestForOwner(operatorScheme, operatorRESTMapper, &operatorv1beta1.ExternalDNS{}, handler.OnlyControllerOwner()))); err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| smInformer := &unstructured.Unstructured{} | ||
| smInformer.SetGroupVersionKind(serviceMonitorGVK) | ||
| if err := c.Watch(source.Kind[client.Object](operatorCache, smInformer, handler.EnqueueRequestForOwner(operatorScheme, operatorRESTMapper, &operatorv1beta1.ExternalDNS{}, handler.OnlyControllerOwner()))); err != nil { | ||
| return nil, err | ||
| } | ||
|
Comment on lines
+110
to
+114
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Description: Check how the ServiceMonitor GVK is declared, whether the CRD is a declared dependency, and whether any availability gate exists.
set -euo pipefail
# 1. Where serviceMonitorGVK is defined.
rg -nP -C5 'serviceMonitorGVK' pkg/
# 2. Is monitoring.coreos.com registered in the operator scheme?
rg -nP -C5 'monitoring\.coreos\.com|monitoringv1|AddToScheme' pkg/operator --glob '*.go'
# 3. Does the bundle/CSV declare a required CRD or a dependency on Prometheus Operator?
fd -t f -e yaml . bundle config --exec rg -nl 'monitoring\.coreos\.com' {} \;
# 4. Any existing RESTMapper/discovery based capability check in the repo to reuse?
rg -nP -C4 'RESTMapper\(\)\.RESTMapping|KindFor|ServerResourcesForGroupVersion|discovery\.' pkg/Repository: openshift/external-dns-operator Length of output: 11026 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- controller setup and ServiceMonitor reconciliation ---'
sed -n '55,145p' pkg/operator/operator.go
sed -n '80,180p' pkg/operator/controller/externaldns/controller.go
sed -n '1,180p' pkg/operator/controller/externaldns/servicemonitor.go
printf '%s\n' '--- bundle and deployment metadata ---'
for f in bundle/manifests/external-dns-operator.clusterserviceversion.yaml \
bundle/manifests/external-dns-operator-metrics-monitor_monitoring.coreos.com_v1_servicemonitor.yaml \
config/prometheus/monitor.yaml \
config/rbac/role.yaml; do
echo "### $f"
rg -n -C4 'monitoring\.coreos\.com|ServiceMonitor|prometheus|related|required|CRD' "$f" || true
done
printf '%s\n' '--- dependency and controller-runtime versions ---'
rg -n 'controller-runtime|k8s.io/api|k8s.io/apimachinery' go.mod go.sum | head -30
printf '%s\n' '--- all ServiceMonitor call sites and discovery gates ---'
rg -n -C3 'ensureExternalDNSServiceMonitor|serviceMonitorGVK|RESTMapper|APIResource|ServerResources|NoMatchError' --glob '*.go' .Repository: openshift/external-dns-operator Length of output: 50388 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- operator setup ---'
sed -n '55,150p' pkg/operator/operator.go
sed -n '1,150p' pkg/operator/controller/externaldns/controller.go
sed -n '1,180p' pkg/operator/controller/externaldns/servicemonitor.go
printf '%s\n' '--- bundle metadata ---'
for f in bundle/manifests/external-dns-operator.clusterserviceversion.yaml \
bundle/manifests/external-dns-operator-metrics-monitor_monitoring.coreos.com_v1_servicemonitor.yaml \
config/prometheus/monitor.yaml \
config/rbac/role.yaml; do
echo "### $f"
rg -n -C3 'monitoring\.coreos\.com|ServiceMonitor|prometheus|related|required|CRD' "$f" || true
done
printf '%s\n' '--- dependency version ---'
rg -n 'controller-runtime' go.mod
printf '%s\n' '--- source.Kind and cache startup ---'
rg -n -C8 'func Kind|GetInformer|Start\(ctx|WaitForCacheSync|ListAndWatch|NewListWatchFromClient' \
vendor/sigs.k8s.io/controller-runtime/pkg/source \
vendor/sigs.k8s.io/controller-runtime/pkg/cache \
vendor/sigs.k8s.io/controller-runtime/pkg/internalRepository: openshift/external-dns-operator Length of output: 50387 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- TypedKind implementation ---'
sed -n '90,180p' vendor/sigs.k8s.io/controller-runtime/pkg/source/source.go
printf '%s\n' '--- controller source registration ---'
rg -n -C12 'func \(.*\) Watch|Add\(.*Source|WaitForSync' \
vendor/sigs.k8s.io/controller-runtime/pkg/controller/controller.go \
vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go \
vendor/sigs.k8s.io/controller-runtime/pkg/source/source.go
printf '%s\n' '--- informer construction and dynamic REST mapping ---'
sed -n '120,230p' vendor/sigs.k8s.io/controller-runtime/pkg/cache/internal/informers.go
rg -n -C12 'func \(.*\) Get|NewFilteredListWatch|RESTMapping|ResourceFor' \
vendor/sigs.k8s.io/controller-runtime/pkg/cache/internal/informers.go \
vendor/sigs.k8s.io/controller-runtime/pkg/internal \
vendor/sigs.k8s.io/controller-runtime/pkg/client
printf '%s\n' '--- cache startup and sync ---'
rg -n -C10 'func \(.*\) Start|WaitForCacheSync|Start\(ctx' \
vendor/sigs.k8s.io/controller-runtime/pkg/cache/informer_cache.go \
vendor/sigs.k8s.io/controller-runtime/pkg/cache/internal/informers.go \
vendor/sigs.k8s.io/controller-runtime/pkg/controller/controller.goRepository: openshift/external-dns-operator Length of output: 50388 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- TypedKind and WaitForSync ---'
sed -n '80,115p' vendor/sigs.k8s.io/controller-runtime/pkg/source/source.go
rg -n -C20 'func \(.*kind.*\) Start|func \(.*kind.*\) WaitForSync|GetInformer' \
vendor/sigs.k8s.io/controller-runtime/pkg/source/source.go
printf '%s\n' '--- manager propagation of controller startup errors ---'
rg -n -C15 'Start.*Runnable|Start.*Controller|failed to start|Runnable.*Start|WaitForCacheSync' \
vendor/sigs.k8s.io/controller-runtime/pkg/manager \
vendor/sigs.k8s.io/controller-runtime/pkg/internal/manager
printf '%s\n' '--- platform scope and ServiceMonitor assumptions ---'
rg -n -C4 'IsOpenShift|ServiceMonitor|monitoring|prometheus|OpenShift|Kubernetes' \
README.md docs config deploy bundle pkg --glob '!**/vendor/**' --glob '*.md' --glob '*.yaml' --glob '*.yml' --glob '*.go' 2>/dev/null || true
printf '%s\n' '--- generated CSV dependency sections ---'
sed -n '520,630p' bundle/manifests/external-dns-operator.clusterserviceversion.yaml
rg -n -C5 'dependencies|alm-examples|required|owned|provided|monitoring\.coreos\.com' \
bundle/manifests/external-dns-operator.clusterserviceversion.yamlRepository: openshift/external-dns-operator Length of output: 1387 🏁 Script executed: #!/bin/bash
set -u
printf '%s\n' '--- internal Kind source ---'
rg -n -C15 'type Kind|func \(.*Kind.*\) Start|func \(.*Kind.*\) WaitForSync|GetInformer' \
vendor/sigs.k8s.io/controller-runtime/pkg/internal \
vendor/sigs.k8s.io/controller-runtime/pkg/source || true
printf '%s\n' '--- manager startup error handling ---'
rg -n -C12 'Start.*Runnable|failed to start|WaitForCacheSync|Start.*Controller' \
vendor/sigs.k8s.io/controller-runtime/pkg/manager \
vendor/sigs.k8s.io/controller-runtime/pkg/internal/manager || true
printf '%s\n' '--- platform and dependency references ---'
rg -n -C4 'IsOpenShift|ServiceMonitor|monitoring|prometheus|OpenShift|Kubernetes' \
README.md docs config deploy bundle pkg \
--glob '!**/vendor/**' \
--glob '*.md' --glob '*.yaml' --glob '*.yml' --glob '*.go' 2>/dev/null || true
printf '%s\n' '--- CSV dependency sections ---'
sed -n '520,630p' bundle/manifests/external-dns-operator.clusterserviceversion.yaml
rg -n -C5 'dependencies|alm-examples|required|owned|provided|monitoring\.coreos\.com' \
bundle/manifests/external-dns-operator.clusterserviceversion.yaml || trueRepository: openshift/external-dns-operator Length of output: 50390 Gate the The watch starts only when the manager starts, not during 🤖 Prompt for AI Agents |
||
|
|
||
|
Thealisyed marked this conversation as resolved.
|
||
| // secret replicated by the credentials controller | ||
| // needs to trigger the reconciliation of the corresponding ExternalDNS | ||
| // because of the annotation with the secret's hash in the operand deployment | ||
|
|
@@ -212,6 +223,13 @@ func (r *reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu | |
| return reconcile.Result{}, fmt.Errorf("failed to ensure externalDNS deployment: %w", err) | ||
| } | ||
|
|
||
| if err := r.ensureExternalDNSMetricsService(ctx, r.config.Namespace, externalDNS); err != nil { | ||
| return reconcile.Result{}, fmt.Errorf("failed to ensure externalDNS metrics service: %w", err) | ||
| } | ||
| if err := r.ensureExternalDNSServiceMonitor(ctx, r.config.Namespace, externalDNS); err != nil { | ||
| return reconcile.Result{}, fmt.Errorf("failed to ensure externalDNS service monitor: %w", err) | ||
| } | ||
|
|
||
| if err := r.updateExternalDNSStatus(ctx, externalDNS, currentDeployment, true); err != nil { | ||
| return reconcile.Result{}, fmt.Errorf("failed to update externalDNS custom resource %s: %w", externalDNS.Name, err) | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.