Skip to content

fix: clear compliance_status and paused_resources when asset is skipped - #291

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift-virtualization:mainfrom
rlobillo:CNV-94678
Aug 11, 2026
Merged

fix: clear compliance_status and paused_resources when asset is skipped#291
openshift-merge-bot[bot] merged 1 commit into
openshift-virtualization:mainfrom
rlobillo:CNV-94678

Conversation

@rlobillo

@rlobillo rlobillo commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Short Description

Two early-return paths in ReconcileAsset left compliance_status and paused_resources stale when an asset was skipped — keeping the last managed value indefinitely until the operator pod restarted.

More Details

When an asset enters unmanaged mode (platform.kubevirt.io/mode: unmanaged) or is excluded via disabled-resources annotation (Root Exclusion), the reconciler returns early without clearing metrics. This causes:

  • compliance_status stays at 1 (synced) → false positive: the operator is not verifying the asset at all.
  • paused_resources stays at 1 if the asset had been in an edit war before the transition → spurious VirtPlatformThrashingDetected alert.

The Root Exclusion path is the only exclusion mechanism with this problem. Assets excluded via allowlist, missing gate CRD, or unmet conditions are correctly handled by CleanupExcludedAssetDeleteAssetMetrics at the controller level before reaching ReconcileAsset.

customization_info is intentionally not cleared in the Root Exclusion path: the underlying annotations (patch, ignore, unmanaged) persist on the object while excluded, so the metric accurately reflects their presence and will be re-evaluated when exclusion is lifted.

What this PR does / why we need it

  • Adds ClearCompliance helper to pkg/observability/metrics.go (with unit test).
  • Calls ClearCompliance(desired) + SetPaused(desired, false) in both the unmanaged and Root Exclusion early-return paths of ReconcileAsset.
  • Stabilises resilience_e2e_test.go: replaces direct metric capture + post-loop Expect with touchHCO() + waitForReconcileSucceeded() to guarantee all gauges are populated before freezing the baseline snapshot.
  • Adds E2E assertions in user_override_test.go: compliance_status absent while unmanaged, re-emitted as 1 after resuming managed mode.
  • Adds E2E assertions in controller_e2e_test.go: compliance_status cleared while excluded, paused_resources not stuck at 1; new It covering the unmanaged→excluded transition (verifies customization_info persists while excluded, compliance_status is cleared).

Fixes: CNV-94678
Related: CNV-92583

@tiraboschi

Copy link
Copy Markdown
Member

/rebase

When an asset enters unmanaged mode (mode=unmanaged annotation) or is
excluded via the disabled-resources annotation (Root Exclusion), two
gauges were left stale:

- compliance_status retained the last managed value (typically 1=synced),
  falsely implying the operator is actively verifying the asset.
- paused_resources could remain stuck at 1 if the asset had been in
  an edit war before the transition, triggering spurious alerts.

Fix: call ClearCompliance(desired) and SetPaused(desired, false) in both
early-return paths. customization_info is intentionally left untouched in
the Root Exclusion path — the underlying annotations (patch, ignore,
unmanaged) persist on the object while excluded, so the metric accurately
reflects their presence and will be re-evaluated when exclusion is lifted.

Also stabilise resilience_e2e_test.go: replace the direct metric capture
+ post-loop Expect with touchHCO()+waitForReconcileSucceeded() to
guarantee all gauges are populated before freezing the baseline snapshot.

New test coverage:
- user_override_test.go: compliance_status absent while unmanaged,
  re-emitted as 1 after resuming managed mode
- controller_e2e_test.go: compliance_status cleared while excluded,
  paused_resources not stuck at 1; and a new It covering the
  unmanaged→excluded transition (customization_info persists,
  compliance_status is cleared)

Fixes: CNV-94678
Related: CNV-92583

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@tiraboschi

Copy link
Copy Markdown
Member

/approve

@tiraboschi

Copy link
Copy Markdown
Member

/cherry-pick release-4.22

@openshift-cherrypick-robot

Copy link
Copy Markdown

@tiraboschi: once the present PR merges, I will cherry-pick it on top of release-4.22 in a new PR and assign it to you.

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.

@openshift-ci

openshift-ci Bot commented Aug 11, 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

@openshift-merge-bot
openshift-merge-bot Bot merged commit 841fbc3 into openshift-virtualization:main Aug 11, 2026
7 checks passed
@openshift-cherrypick-robot

Copy link
Copy Markdown

@tiraboschi: new pull request created: #298

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