cdi: expose secure pprof endpoints for controller and operator #4161
/cc @akalenyu

coverage: 49.435% (-0.1%) from 49.56% — Acedus:add-pprof-endpoints into kubevirt:main
/test pull-containerized-data-importer-non-csi-hpp
/approve
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: <a href="https://github.com/kubevirt/containerized-data-importer/pull/4161#pullrequestreview-4418675020" title="Approved">akalenyu</a>
The full list of commands accepted by this bot can be found here.
The pull request process is described here
<details >
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
</details>
<!-- META={"approvers":[]} -->
cool!
dsanatar
Acedus
<!-- Thanks for sending a pull request! Here are some tips for you:
1. Follow the instructions for writing a release note from k8s: https://git.k8s.io/community/contributors/guide/release-notes.md
-->
What this PR does / why we need it:
pprof is Go's built-in profiling toolkit that exposes runtime diagnostics (e.g., heap allocations, goroutine stacks, CPU profiles, etc.) over HTTP. Exposing these endpoints enables live debugging of memory leaks, goroutine leaks, and CPU hotspots in running controller and operator pods without redeployment or recompilation.
This PR exposes the handlers via the existing metrics server by relying on controller-runtime's ExtraHandlers along with the previously introduced
WithAuthenticationAndAuthorizationwhich serves to secure the handlers with TLS and RBAC auth. A new ClusterRole (cdi-pprof-reader) is added to grant pprof access independently of metrics scraping.Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
Registering the handlers adds no runtime overhead, the Go runtime already tracks the underlying profiling data, and CPU/trace profiles only activate on-demand when explicitly requested.
This PR depends on https://github.com/kubevirt/containerized-data-importer/pull/4121, review only the last commit.
Release note:
<!-- Write your release note:
1. Enter your extended release note in the below block. If the PR requires additional action from users switching to the new release, include the string "action required".
2. If no release note is required, just write "NONE".
-->
``
release-note
``Expose secure pprof endpoints on controller and operator for live runtime diagnostics