Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b36fc1e
fix: replace non-expiring metrics monitor SA token with TokenRequest
tzprograms Jul 13, 2026
406b8ed
fix: improve metrics bearer token Secret reconciliation
alkakumari016 Aug 15, 2026
3f7a01a
fix: keep CSV operator-sdk builder annotation at v1.35.0
alkakumari016 Aug 17, 2026
503c2e5
Merge branch 'master' of github.com:redhat-developer/gitops-operator …
alkakumari016 Aug 17, 2026
c56b307
minimise requeue calls assisted-by: claude-code
alkakumari016 Aug 18, 2026
544324e
fix: delete and recreate legacy metrics bearer token Secret on migrat…
alkakumari016 Aug 19, 2026
75c686b
Merge branch 'master' of github.com:redhat-developer/gitops-operator …
alkakumari016 Aug 19, 2026
135b367
fix: handover creation of operator metrics ServiceMonitor to controll…
alkakumari016 Aug 27, 2026
f930bea
Merge branch 'master' of github.com:redhat-developer/gitops-operator …
alkakumari016 Aug 27, 2026
9ad766e
Handle the refresh result after minting
alkakumari016 Aug 27, 2026
f19957f
resolved lint error
alkakumari016 Aug 27, 2026
1d6fc3a
Trigger tests
alkakumari016 Aug 27, 2026
5401334
resolved review comments
alkakumari016 Sep 2, 2026
3bf2e35
Merge branch 'master' of github.com:redhat-developer/gitops-operator …
alkakumari016 Sep 2, 2026
71d2c63
fix formatting error
alkakumari016 Sep 15, 2026
eb48f48
Merge branch 'master' of github.com:redhat-developer/gitops-operator …
alkakumari016 Sep 17, 2026
c1032d3
rebased to master, added reviewed changes
alkakumari016 Sep 17, 2026
fbd3ac6
fix failing xks test
alkakumari016 Sep 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

8 changes: 8 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,14 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "Argo CD metrics")
os.Exit(1)
}

if err = (&controllers.OperatorMetricsTokenReconciler{
Client: client,
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Operator metrics token")
os.Exit(1)
}
} else {
setupLog.Info("Monitoring API not found, skipping Argo CD metrics controller setup")
}
Expand Down
37 changes: 2 additions & 35 deletions config/prometheus/monitor.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
---
apiVersion: v1
kind: Secret
metadata:
name: metrics-monitor-bearer-token
namespace: openshift-gitops-operator
annotations:
kubernetes.io/service-account.name: openshift-gitops-operator-controller-manager
type: kubernetes.io/service-account-token
---
# CA bundle for the operator metrics ServiceMonitor TLS config. The ServiceMonitor
# itself is created by OperatorMetricsTokenReconciler after the bearer token Secret.
apiVersion: v1
kind: ConfigMap
metadata:
Expand All @@ -18,29 +11,3 @@ metadata:
service.beta.openshift.io/inject-cabundle: "true"
name: metrics-monitor-ca-bundle
namespace: openshift-gitops-operator
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: metrics-monitor
namespace: openshift-gitops-operator
labels:
control-plane: gitops-operator
spec:
selector:
matchLabels:
control-plane: gitops-operator
endpoints:
- bearerTokenSecret:
name: openshift-gitops-operator-metrics-monitor-bearer-token
key: token
interval: 30s
path: /metrics
port: metrics
scheme: https
tlsConfig:
ca:
configMap:
name: openshift-gitops-operator-metrics-monitor-ca-bundle
key: service-ca.crt
serverName: openshift-gitops-operator-metrics-service.openshift-gitops-operator.svc
1 change: 0 additions & 1 deletion controllers/argocd_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ const (

var (
encodedArgoImage string

//go:embed argocd/img/argo.png
argoImage []byte
)
Expand Down
51 changes: 3 additions & 48 deletions controllers/argocd_metrics_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"embed"
"fmt"
"os"
"path/filepath"
"strings"

Expand Down Expand Up @@ -48,11 +47,9 @@ const (
readRoleBindingNameFormat = "%s-prometheus-k8s-read-binding"
alertRuleName = "gitops-operator-argocd-alerts"
// Use a separate rule so upgrades install the sync-loop alerts.
syncLoopAlertRuleName = "gitops-operator-argocd-sync-loop-alerts"
dashboardNamespace = "openshift-config-managed"
dashboardFolder = "dashboards"
operatorMetricsServiceName = "openshift-gitops-operator-metrics-service"
operatorMetricsMonitorName = "openshift-gitops-operator-metrics-monitor"
syncLoopAlertRuleName = "gitops-operator-argocd-sync-loop-alerts"
dashboardNamespace = "openshift-config-managed"
dashboardFolder = "dashboards"
)

type ArgoCDMetricsReconciler struct {
Expand Down Expand Up @@ -184,11 +181,6 @@ func (r *ArgoCDMetricsReconciler) Reconcile(ctx context.Context, request reconci
if err != nil {
return reconcile.Result{}, err
}

err = r.reconcileOperatorMetricsServiceMonitor(reqLogger)
if err != nil {
return reconcile.Result{}, err
}
} else {
if exists {
namespace.Labels[monitoringLabel] = "false"
Expand Down Expand Up @@ -373,43 +365,6 @@ func (r *ArgoCDMetricsReconciler) deleteServiceMonitor(name string, namespace st

}

func (r *ArgoCDMetricsReconciler) reconcileOperatorMetricsServiceMonitor(reqLogger logr.Logger) error {

data, err := os.ReadFile(operatorPodNamespacePath)
if err != nil {
if os.IsNotExist(err) {
reqLogger.Info(fmt.Sprintf("Unable to retrieve the operator's running namespace via '%s': you should only see this message when running within unit tests, otherwise it is an error.", operatorPodNamespacePath))
return nil
}
reqLogger.Error(err, "Error retrieving operator's running namespace")
return err
}

operatorNS := string(data)
desiredMetricsServerName := operatorMetricsServiceName + "." + operatorNS + ".svc"

existingServiceMonitor := &monitoringv1.ServiceMonitor{}
err = r.Client.Get(context.TODO(), types.NamespacedName{Name: operatorMetricsMonitorName, Namespace: operatorNS}, existingServiceMonitor)

if err != nil {
if !errors.IsNotFound(err) {
reqLogger.Error(err, "Error querying for ServiceMonitor", "Namespace", operatorNS, "Name", operatorMetricsMonitorName)
return err
}

// no svc monitor found, nothing to do
return nil
}

currentServerName := existingServiceMonitor.Spec.Endpoints[0].TLSConfig.ServerName
if currentServerName == nil || *currentServerName != desiredMetricsServerName {
existingServiceMonitor.Spec.Endpoints[0].TLSConfig.ServerName = &desiredMetricsServerName
return r.Client.Update(context.TODO(), existingServiceMonitor)
}

return nil
}

func (r *ArgoCDMetricsReconciler) createPrometheusRulesIfAbsent(namespace string, argocd *argoapp.ArgoCD, reqLogger logr.Logger) error {
if err := r.createPrometheusRuleIfAbsent(newPrometheusRule(namespace), argocd, reqLogger); err != nil {
return err
Expand Down
Loading
Loading