operator: always use controller-runtime metric registry as base #36243
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, the Cilium Operator only uses the metrics registry of the
controller-runtime
as base registry if Gateway API functionality is enabled. This has historic reasons as Gateway API functionality was the first module that usedcontroller-runtime
for its controllers.In the meantime, other modules (Ingress Controller, Secret Sync, ...) are using the
controller-runtime
too - but the metrics registry of the library is still only used if Gateway API is enabled. In these cases, the metrics of thecontroller-runtime
library (https://book.kubebuilder.io/reference/metrics-reference) aren't exposed.Therefore, this commit changes the behaviour, that the metrics registry of the
controller-runtime
library is always used as the base registry.Note: Unfortunately, the
controller-runtime
library configures the base registry to have Go runtime metrics included by default (https://github.com/cilium/cilium/blob/main/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/metrics/metrics.go#L91-L92). Therefore, this Go metrics collector has to be removed from the metrics registry before registering a new Go metrics collector with custom Go runtime metrics enabled. Otherwise the registration fails because some Go runtime metrics are registered twice.Related PRs:
controller-runtime
integration into its own Hive Cell)