hcloud-cloud-controller-manager icon indicating copy to clipboard operation
hcloud-cloud-controller-manager copied to clipboard

feat: look up CCM-managed certificates before creating them on every reconcilement

Open lukasmetzner opened this issue 3 months ago • 3 comments

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.

lukasmetzner avatar Sep 02 '26 14:09 lukasmetzner

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 avatar Nov 25 '26 08:11 srijan399

@srijan399 Feel free to work on this issue.

lukasmetzner avatar Nov 25 '26 15:11 lukasmetzner

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

srijan399 avatar Nov 27 '26 07:11 srijan399