Skip to content

Reconcile error: Controller tries to resolve RemoteClusterAccessRef when not specified #24

@maximiliantech

Description

@maximiliantech

Problem

After successfully installing the metrics-operator, I wanted to create my first very basic metric, see

https://github.com/SAP/metrics-operator/blob/bd720c24038b1b75a858070c76cc7902e016e6a5/examples/basic_metric.yaml#L14-L28

The metric is setup to look at the pods in the same cluster where the metrics-operator runs.
After that, nothing happened - no status change.

When looking at the logs, I can see the following error message:

...
2025-06-02T11:24:42Z    INFO    controllers.Metric    Reconciling Metric    {"namespace": {"name":"basic-pods","namespace":"default"}, "name": "basic-pods"}
2025-06-02T11:24:42Z    INFO    Warning: Reconciler returned both a non-zero result and a non-nil error. The result will always be ignored if the error is non-nil and the non-nil error causes requeuing with exponential backoff. For more details, see: https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/reconcile#Reconciler    {"controller": "metric", "controllerGroup": "metrics.cloud.sap", "controllerKind": "Metric", "Metric": {"name":"basic-pods","namespace":"default"}, "namespace": "default", "name": "basic-pods", "reconcileID": "7feb6bc5-411d-432a-9124-8756682d29e5"}
2025-06-02T11:24:42Z    ERROR    Reconciler error    {"controller": "metric", "controllerGroup": "metrics.cloud.sap", "controllerKind": "Metric", "Metric": {"name":"basic-pods","namespace":"default"}, "namespace": "default", "name": "basic-pods", "reconcileID": "7feb6bc5-411d-432a-9124-8756682d29e5", "error": "failed to retrieve Remote Cluster Acces Ref with name  in namespace : RemoteClusterAccess.metrics.cloud.sap \"\" not found"}
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler
    /home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:341
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem
    /home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:288
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2
    /home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:249

So the controller is complaining about: failed to retrieve Remote Cluster Acces Ref with name in namespace. But it should not look up any RemoteClusterAccess CR because the Metric CR is not specifying any reference to it and the Pods should be observed in the same cluster.

Important links

It looks like this code below gets called, even if we are not specifying any RemoteClusterAccessRef:

https://github.com/SAP/metrics-operator/blob/3cc44c348d545da3b76a74bfb5ecbf3312866e5f/internal/controller/metric_controller.go#L267-L268

Could it be possible that the reference gets defaulted somehow?

Solution

The issue could come from
https://github.com/SAP/metrics-operator/blob/3cc44c348d545da3b76a74bfb5ecbf3312866e5f/api/v1alpha1/metric_types.go#L59
This is just a pointer struct reference without having its own field.

We should change that in ALL metric resources where this pointer struct will get used.

Metadata

Metadata

Assignees

Labels

good first issueNew to this repo? This is a good place to starthelp wantedExtra attention is needed

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions