Skip to content

fix: don't fabricate a Ready condition for generic objects in metrics#212

Open
DerekFrank wants to merge 1 commit into
awslabs:mainfrom
DerekFrank:karpenter-1.14
Open

fix: don't fabricate a Ready condition for generic objects in metrics#212
DerekFrank wants to merge 1 commit into
awslabs:mainfrom
DerekFrank:karpenter-1.14

Conversation

@DerekFrank

Copy link
Copy Markdown
Contributor

Problem

GenericObjectController wraps objects in an UnstructuredAdapter whose StatusConditions() calls NewReadyConditions(...).For(u). For() initializes any missing root/dependent condition type to Unknown. For an object that does not define a Ready condition, this fabricates a Ready=Unknown in the adapter's in-memory condition list, which the reconcile gauge loop then emits as a permanent metric:

operator_status_condition_count{type="Ready", status="Unknown", reason="AwaitingReconciliation"} 1

Nothing is ever persisted to the object (the adapter is a throwaway unstructured copy), and the synthetic Ready never rolls up, so it's stuck at Unknown forever — misleading noise for any object whose API doesn't use a Ready root condition.

Fix

Add a WithObservedOnly() ForOption that builds the ConditionSet from the conditions already present on the object, skipping initialization of absent root/dependent conditions to Unknown. The UnstructuredAdapter — a read-only reflection used only for metrics on objects the controller does not own — uses it, so it reports metrics for the conditions that actually exist and no longer fabricates a Ready.

Objects that own their status and drive reconcile (via NewController[T] with a typed status.Object) are unaffected: For() still initializes their declared conditions to Unknown as before.

Testing

Added a generic-controller test asserting no Ready metric is emitted for an object that defines only non-Ready conditions. Verified it fails before the fix (phantom Ready=Unknown) and passes after. Full status suite passes.

Motivation

Karpenter is adding operator_status_condition_* metrics for the CapacityBuffer CRD (whose conditions are ReadyForProvisioning/Provisioning/LimitedByQuotas, with no Ready) via GenericObjectController, and was seeing a permanent phantom Ready=Unknown series.

GenericObjectController wraps objects in an UnstructuredAdapter whose
StatusConditions() called NewReadyConditions(...).For(), and For()
initializes any missing root/dependent condition to Unknown. For an object
that does not define a Ready condition, this fabricated a Ready=Unknown that
was then emitted as a permanent operator_status_condition_*{type="Ready",
status="Unknown"} metric, even though nothing is persisted to the object.

Add a WithObservedOnly ForOption that builds the ConditionSet from the
conditions already present without initializing absent ones, and use it from
the UnstructuredAdapter (a read-only reflection used only for metrics). Owned
objects driving reconcile are unaffected.
@DerekFrank DerekFrank marked this pull request as ready for review July 8, 2026 17:54
@DerekFrank DerekFrank requested a review from a team as a code owner July 8, 2026 17:54

@jmdeal jmdeal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants