← Back to Pull requests

[ARO-28373] Initial implementation of ClusterResourcesController #6070

Closed
unknown closed this pull request without merging on Sep 05, 2026 10:16 UTC
View on GitHub
unknown unknown commented on Jul 14, 2026 12:32 UTC
Author

https://redhat.atlassian.net/browse/ARO-28373

What

An initial implementation of a ClusterResourcesController which polls the newly created /resources endpoint and creates an ApplyDesire document for each resource recieved.

Why

This is part of the deprecation of ACM's Manifestwork as well as the entire Maestro pipeline for the new kube-applier component.

For more information see here.

Important subtelty concerning deletion:


Since the list of desired resources is a simple list the controller applies blindly the number of ApplyDesire docs may grow without limit. To resolve this we have added a simple mechanism to ensure only the _current_ received resources are to be applied and whatever remains ("stale resources") are to be removed:

The ApplyDesire deletion happens in two paths:

1. ClusterResourcesController cleanup (deleteStaleApplyDesires method in ClusterResourcesController):
While the cluster is running, if a resource disappears from the Cluster Service response (e.g., a nodepool's resources are removed), this function cleans up the corresponding ApplyDesires. It only touches desires tagged clusterresource (our controller's) and uses a two-phase approach: first marks the desire as Type=Delete so kube-applier removes the Kubernetes object, then purges the Cosmos document once the ReadDesire confirms the object is gone.

2. Cluster deletion (deleteAllOwnedApplyDesires in ClusterResourcesController)
When a cluster is being fully deleted, this function lists ALL ApplyDesires for the cluster and deletes them directly from Cosmos - no tag filtering, no two-phase.

Testing

Testing is required for feature completion and tests should be part of the pull
request along with the feature changes.

How was this tested?


  • Created a cluster.

  • Created two NodePools

  • Observed the ApplyDesire documents where created for both nodepools.

  • Deleted 1 nodepools -

  • - Observed the deletion of the resource from the resources list.
    - Observed the deletion of the ApplyDesire and ReadDesire for it.
    - Deleted the cluster observed the deletion of ApplyDesires.

    {"time":"2026-08-19T10:43:50.27509533Z","level":"INFO","source":{"function":"github.com/Azure/ARO-HCP/backend/pkg/controllers/clusterresources.(*clusterResourcesController).processClusterResources","file":"/app/backend/pkg/controllers/clusterresources/cluster_resources_controller.go","line":196},"msg":"synced ApplyDesire for resource","controller_name":"clusterresourcescontroller","subscription_id":"1d3378d3-5a3f-4712-85a1-2485495dfc4b","resource_group":"rg-hs-pre--2dpcn8xlqk6c","resourceType":"microsoft.redhatopenshift/hcpopenshiftclusters","resource_name":"cluster-hs-pre-85grct","resource_id":"/subscriptions/1d3378d3-5a3f-4712-85a1-2485495dfc4b/resourcegroups/rg-hs-pre--2dpcn8xlqk6c/providers/microsoft.redhatopenshift/hcpopenshiftclusters/cluster-hs-pre-85grct","hcp_cluster_name":"/subscriptions/1d3378d3-5a3f-4712-85a1-2485495dfc4b/resourcegroups/rg-hs-pre--2dpcn8xlqk6c/providers/microsoft.redhatopenshift/hcpopenshiftclusters/cluster-hs-pre-85grct","resourceKey":"secret.ocm-arohcppers-2s9jcfl4mggtun7tfi4jbuksjtb71ok3.r8h4j0x3h7k5x9s-pull","desireName":"secrets.ocm-arohcppers-2s9jcfl4mggtun7tfi4jbuksjtb71ok3.r8h4j0x3h7k5x9s-pull"}
    {"time":"2026-08-19T10:43:50.278791686Z","level":"INFO","source":{"function":"github.com/Azure/ARO-HCP/backend/pkg/controllers/clusterresources.(*clusterResourcesController).processClusterResources","file":"/app/backend/pkg/controllers/clusterresources/cluster_resources_controller.go","line":196},"msg":"synced ApplyDesire for resource","controller_name":"clusterresourcescontroller","subscription_id":"1d3378d3-5a3f-4712-85a1-2485495dfc4b","resource_group":"rg-hs-pre--2dpcn8xlqk6c","resourceType":"microsoft.redhatopenshift/hcpopenshiftclusters","resource_name":"cluster-hs-pre-85grct","resource_id":"/subscriptions/1d3378d3-5a3f-4712-85a1-2485495dfc4b/resourcegroups/rg-hs-pre--2dpcn8xlqk6c/providers/microsoft.redhatopenshift/hcpopenshiftclusters/cluster-hs-pre-85grct","hcp_cluster_name":"/subscriptions/1d3378d3-5a3f-4712-85a1-2485495dfc4b/resourcegroups/rg-hs-pre--2dpcn8xlqk6c/providers/microsoft.redhatopenshift/hcpopenshiftclusters/cluster-hs-pre-85grct","resourceKey":"secretproviderclass.open-cluster-management-policies.default-ingress-tls-cert-2s9jcfl4mggtun7tfi4jbuksjtb71ok3","desireName":"secretproviderclasses.open-cluster-management-policies.default-ingress-tls-cert-2s9jcfl4mggtun7tfi4jbuksjtb71ok3"}
    

    UT were Added.

  • Unit tests

  • Integration tests

  • E2E tests
  • Special notes for your reviewer

    Important: This is a work in progress for visibility and debugging.

    PR Checklist

  • PR is scoped to a single task (no mixed concerns)

  • Title follows Conventional Commits format

  • Summary explains the "Why" behind the change

  • Linked to relevant ticket/issue

  • Screenshots included (if graph/UI/metrics changes)

  • Self-reviewed the diff

  • CI/CD checks are passing (ignore Tide)

  • Draft PR used for WIP (if applicable)

  • Commit history is clean (rebased/squashed)

  • Tricky code blocks are commented

  • Specific reviewers tagged

  • All comment threads resolved before merge
  • If E2E tests are included:

  • E2E tests follow Principles of Good E2E Test Case Design

  • If new E2E use case is covered (via a new test or new check/verifier),

  • demonstrate that the test is able to detect a defect/error and fail with
    proper error message and logs which communicates nature of the problem.

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: nimrodshn Review duration: 76184m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #6070"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%
    Repository