feat: look up CCM-managed certificates before creating them on every reconcilement
For a Service with http-certificate-type: managed, reconcileManagedCertificate issues a POST /certificates on every single reconcilement and just swallows the resulting uniqueness error, even though the certificate is looked up by its service-UID label right afterwards anyway.
We should look it up first and only create it when it is missing (still tolerating ErrAlreadyExists for the concurrent-create race), which cuts the steady state from a guaranteed-to-fail write plus a list down to a single list.
We can probably reuse our cache package here.
Hello, @lukasmetzner if the issue's still open, I'd like to work on this if my proposal sounds good From what I understood: The controller tries to create a managed certificate on every reconciliation, even when it already exists. Checking first would avoid unnecessary API requests.
How I want to approach:
- Look up the certificate by its Service UID label and reuse it.
- Create it only when missing, while handling concurrent creation safely.
- Add tests for existing certificates, creation and error handling.
@srijan399 Feel free to work on this issue.
Thanks, I’ve opened #1424 with the lookup-first fix and regression tests. The local unit tests pass, including race detection. Would love feedback on it @lukasmetzner