villebro opened a new pull request, #361:
URL: https://github.com/apache/superset-kubernetes-operator/pull/361
## Summary
The operator watches two optional CRDs — Gateway API `HTTPRoute` and
Prometheus `ServiceMonitor` — only when they're installed, detecting
availability via `RESTMapper.RESTMapping`. Both guards passed only a
`GroupKind` (no version), so they matched when **any** version of the Kind was
served. The controller then registered a watch for the *specific* version it
reconciles: Gateway API `v1` (`Owns(&gatewayv1.HTTPRoute{})`) and
`ServiceMonitor` `v1`.
On a cluster where Gateway API is installed but serves only `v1beta1` (any
Gateway API release before 1.0, where `HTTPRoute` graduated to `v1`), the guard
passed but the registered watch targeted a GVK the apiserver does not serve.
That fails the controller's informer cache sync at startup, so the manager
exits and the operator crash-loops — a "works on one cluster, crashes on
another" failure that dev/CI (which install Gateway API `v1`) don't exercise.
## Details
Introduce a small `apiVersionServed(mapper, gvk)` helper that calls
`RESTMapping(gvk.GroupKind(), gvk.Version)` — pinning the version — and use it
for both the HTTPRoute and ServiceMonitor startup guards. An optional API is
now treated as available only when the exact version the operator uses is
served.
The reconcile-time create path already handles this correctly: it operates
on the typed `gatewayv1.HTTPRoute`, so an unserved `v1` returns `NoMatchError`,
which is already swallowed. Only the watch-registration guard was over-eager.
### Tests
`TestAPIVersionServed_PinsVersion` builds a REST mapper serving only
`v1beta1` and asserts the helper returns false for `v1`, true for the served
`v1beta1`, and false for a Kind not served at all.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]