Skip to content

fix(compliance): Handle custom rules when calculating ParentRule#19439

Draft
guzalv wants to merge 3 commits intomaster-base/gualvare/ROX-33477-update-ssb-logic-to-handle-tpfrom
master-base/gualvare/fix-compliance-custom-rules-gotchas
Draft

fix(compliance): Handle custom rules when calculating ParentRule#19439
guzalv wants to merge 3 commits intomaster-base/gualvare/ROX-33477-update-ssb-logic-to-handle-tpfrom
master-base/gualvare/fix-compliance-custom-rules-gotchas

Conversation

@guzalv
Copy link
Contributor

@guzalv guzalv commented Mar 16, 2026

Description

This PR handles the fact that Compliance Operator treats Rules and CustomRules differently when connecting them with the CheckResults they generate:

Check results always have a compliance.openshift.io/rule annotation, but it is built differently based on whether they come from a Rule or a CustomRule:

  • When they come from Rules, their compliance.openshift.io/rule annotation _____WIP:

ComplianceOperatorRuleV2 objects with OperatorKind=CUSTOM_RULE had a broken join with their ComplianceCheckResults.

The join key (RuleRefId) is a deterministic UUID derived from BuildNameRefID(clusterID, parentRule), where parentRule is the value of the compliance.openshift.io/rule annotation. For regular rules, CO sets this annotation on Rule objects, so parentRule is populated correctly on ingest.

For CustomRule objects, CO does not set that annotation — CustomRule is a separate CRD and the annotation convention belongs to Rule. CO's CEL scanner derives the check result annotation from Spec.ID via IDToDNSFriendlyName. As a result, parentRule was always empty for custom rules, producing a RuleRefId
that never matched any check result, breaking the join and causing "Unable to process compliance rule" errors in the UI.

Fix: in the rule converter, detect CUSTOM_RULE kind and derive parentRule from RuleId (which carries Spec.ID) using the same IDToDNSFriendlyName transformation CO applies when setting the check result annotation.

User-facing documentation

Testing and quality

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • added unit tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

How I validated my change

change me!

@openshift-ci
Copy link

openshift-ci bot commented Mar 16, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

guzalv added 3 commits March 16, 2026 23:18
This solves the issue but injects fake data - custom rules don't have
the annotation. Let's implement this in the central converter instead -
we have all the data required there.

This reverts commit 4cd180b.
@rhacs-bot
Copy link
Contributor

Images are ready for the commit at 3416948.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.11.x-356-g34169482ed.

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.

2 participants