Skip to content

fix(metrics): delete stale per-asset metric series when asset leaves active set#220

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift-virtualization:mainfrom
tiraboschi:CNV-89268
Jun 23, 2026
Merged

fix(metrics): delete stale per-asset metric series when asset leaves active set#220
openshift-merge-bot[bot] merged 1 commit into
openshift-virtualization:mainfrom
tiraboschi:CNV-89268

Conversation

@tiraboschi

Copy link
Copy Markdown
Member

When an asset is removed from the autopilot allowlist (or its CRD goes missing, or its condition is no longer met), ReconcileAsset is never called for it, so compliance_status, paused_resources, customization_info, and reconcile_duration_seconds keep their last-written value indefinitely. This produces stale /metrics output that misleads dashboards and may prevent VirtPlatformSyncFailed from firing correctly.

Fix:

  • observability: add DeleteAssetMetrics(kind, name, namespace) that removes all four per-asset series for a resource (safe no-op when the series does not exist, including all customization_info type variants).
  • engine/Patcher: track the rendered kind/name/namespace per asset name in renderedIdentities (populated on every successful template render). Expose CleanupExcludedAssets(activeAssets) that deletes metric series for any asset whose identity is known but is absent from activeAssets, then removes it from the map so repeat calls are no-ops.
  • controller: call CleanupExcludedAssets once per reconciliation cycle after building assetsToReconcile, passing the full active set (non-HCO assets + hco-golden-config when in scope).

Fixes: CNV-89268

@rlobillo

Copy link
Copy Markdown
Contributor

/lgtm

@tiraboschi

Copy link
Copy Markdown
Member Author

/approve

@openshift-ci

openshift-ci Bot commented Jun 23, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tiraboschi

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

…active set

When an asset is removed from the autopilot allowlist (or its CRD goes
missing, or its condition is no longer met), ReconcileAsset is never
called for it, so compliance_status, paused_resources, customization_info,
and reconcile_duration_seconds keep their last-written value indefinitely.
This produces stale /metrics output that misleads dashboards and may
prevent VirtPlatformSyncFailed from firing correctly.

Fix:
- observability: add DeleteAssetMetrics(kind, name, namespace) that removes
  all four per-asset series for a resource (safe no-op when the series does
  not exist, including all customization_info type variants).
- engine/Patcher: track the rendered kind/name/namespace per asset name in
  renderedIdentities (populated on every successful template render).
  Expose CleanupExcludedAssets(activeAssets) that deletes metric series for
  any asset whose identity is known but is absent from activeAssets, then
  removes it from the map so repeat calls are no-ops.
- controller: call CleanupExcludedAssets once per reconciliation cycle after
  building assetsToReconcile, passing the full active set (non-HCO assets +
  hco-golden-config when in scope).

Fixes: CNV-89268

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Simone Tiraboschi <stirabos@redhat.com>
@rlobillo

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm label Jun 23, 2026
@openshift-merge-bot openshift-merge-bot Bot merged commit 072117b into openshift-virtualization:main Jun 23, 2026
7 checks passed
@tiraboschi

Copy link
Copy Markdown
Member Author

/cherry-pick release-4.22

@tiraboschi tiraboschi deleted the CNV-89268 branch June 23, 2026 12:41
@openshift-cherrypick-robot

Copy link
Copy Markdown

@tiraboschi: new pull request created: #225

Details

In response to this:

/cherry-pick release-4.22

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants