Fix: Prevent Nil Pointer Error When Collector Client Is Unavailable
Description:
There is a runtime crash caused by a nil pointer dereference in the metrics server. The issue occurs when a collector client (e.g., Kyverno, NeuVector, or Kubescape) fails to initialize or is unavailable, returning a nil client instance. This results in a crash when metrics are attempted to be collected from the nil client.
Resolution:
Wrapped metric collection logic with conditional checks to ensure the client is non-nil before proceeding. This prevents the crash and allows the collector to continue functioning even if one or more data sources are not running.
Acceptance Criteria:
-
Added nil checks for all collector clients before invoking metric logic
-
Ensured fallback behavior if a source is temporarily unavailable
-
Validated metrics server no longer crashes when one or more data sources are offline
-
Confirmed successful metric collection when all clients are available