← Back to Pull requests

fix: unblock the acm-uninstall controller by ensuring that no resource is still owned by ACM #8165

Closed
unknown closed this pull request without merging on Nov 19, 2026 11:46 UTC
View on GitHub
unknown unknown commented on Nov 18, 2026 07:13 UTC
Author

The PR https://github.com/Azure/ARO-HCP/pull/7406 contained a CS change https://github.com/openshift-online/aro-hcp-clusters-service/commit/f89628c8be96590ee76a3c7c64cd53ab6ba5f253 that ensured that no CR is still managed by Maestro/ACM however there was a design decision to ignore resources that have been in deleting state since the expectation was that deletion was going to just complete. That wasn't the case and we noticed that there are still some ManifestWork that contains various resources e.g HC/HCP Namespace, HostedCluster CR that are still in deletion state. Because of these resources the acm-uninstall controller prereq are not met causing that controller to loop at that state waiting for these ownership to be removed.

To fix that, a new controller is added that ensures the following;

  • If there is still an active ManifestWork for resources of interests to us then sets its deleteOption to Orphan to remove the ownernship.

  • If the ManifestWork is deleting or has been deleted, then remove the finalisers from the corresponding AppliedManifestWork so that it can be deleted

  • Then remove the owner reference from such resources
  • The added controller is intented to simply remove the ownerReferences and not ensure that the resources that were being deleted are deleted. That's a separate initiated whose work is tracked by https://github.com/Azure/ARO-HCP/pull/7762

    These are the kusto queries

    database('ServiceLogs').table('containerLogs') 
    | where cluster contains "pers-usw3many-mgmt" and namespace_name contains "mgmt-agent" and log.controller_name == "acm-uninstall"
    | where timestamp between (datetime("2026-11-18T11:00:39.295Z")..datetime("2026-11-18T11:30:39.295Z"))
    | project timestamp, log
    | order by timestamp asc
    
    database('ServiceLogs').table('containerLogs') 
    | where cluster contains "pers-usw3many-mgmt" and namespace_name contains "mgmt-agent" and log.controller_name == "acm-ownership-cleanup"
    | where timestamp between (datetime("2026-11-18T11:00:39.295Z")..datetime("2026-11-18T11:30:39.295Z"))
    | project timestamp, log
    | order by timestamp asc
    

    That show what the PR brings.

    We can see that the uninstall controller was stuck with logs like

    "timestamp": 2026-11-18T11:13:13.962Z,
    "log": {
    	"level": "INFO",
    	"msg": "ACM uninstall prerequisite not met",
    	"time": "2026-11-18T11:13:13.9622251Z",
    	"source": {
    		"function": "github.com/Azure/ARO-HCP/mgmt-agent/pkg/controller/acmuninstall.(*Controller).reconcile",
    		"file": "/app/mgmt-agent/pkg/controller/acmuninstall/controller.go",
    		"line": 238
    	},
    	"reason": "PodNetwork resources still owned by ACM",
    	"resources": [
    		"PodNetwork/pn-2u5fu4vf03hlbqra220vrl9jm8lodiq8",
    		"PodNetwork/pn-2u5j0qclrcsg8vu5a6jble9k5fml2ubu"
    	],
    	"controller_name": "acm-uninstall",
    	"sync": "acm-uninstall",
    	"step": "ensure-podnetworks-not-acm-owned",
    	"remaining": 2
    }
    

    or

    
    "timestamp": 2026-11-18T11:14:29.496Z,
    "log": {
    	"level": "INFO",
    	"msg": "ACM uninstall prerequisite not met",
    	"time": "2026-11-18T11:14:29.4966624Z",
    	"source": {
    		"function": "github.com/Azure/ARO-HCP/mgmt-agent/pkg/controller/acmuninstall.(*Controller).reconcile",
    		"file": "/app/mgmt-agent/pkg/controller/acmuninstall/controller.go",
    		"line": 238
    	},
    	"reason": "HostedCluster resources still owned by ACM",
    	"resources": [
    		"Namespace/ocm-arohcppers-2u5fu4vf03hlbqra220vrl9jm8lodiq8-z7a3u6w7v0q5z7l",
    		"Namespace/ocm-arohcppers-2u5j0t8jism1kso341ve6je2a8mqjtgi",
    		"Namespace/ocm-arohcppers-2u5j0t8jism1kso341ve6je2a8mqjtgi-r1p8z9r6h9g1g6m"
    	],
    	"controller_name": "acm-uninstall",
    	"sync": "acm-uninstall",
    	"step": "ensure-hostedcluster-resources-not-acm-owned",
    	"remaining": 3
    }
    
    

    And eventually the uninstall prereq were met due to the changes in the PR and we began uninstall the ManagedCluster CRs

    18/11/2026, 11:15:12.302	{"level":"INFO","msg":"ACM uninstall prerequisites satisfied; skipping future ownership checks","time":"2026-11-18T11:15:12.3021078Z","source":{"function":"github.com/Azure/ARO-HCP/mgmt-agent/pkg/controller/acmuninstall.(*Controller).reconcile","file":"/app/mgmt-agent/pkg/controller/acmuninstall/controller.go","line":242},"controller_name":"acm-uninstall","sync":"acm-uninstall"}
    18/11/2026, 11:15:12.9	{"level":"INFO","msg":"deleting ManagedCluster","time":"2026-11-18T11:15:12.9004452Z","source":{"function":"github.com/Azure/ARO-HCP/mgmt-agent/pkg/controller/acmuninstall.(*Controller).ensureManagedClustersDeleted","file":"/app/mgmt-agent/pkg/controller/acmuninstall/controller.go","line":331},"controller_name":"acm-uninstall","sync":"acm-uninstall","managedcluster":"2u5j0qclrcsg8vu5a6jble9k5fml2ubu"}
    18/11/2026, 11:15:13.563	{"level":"INFO","msg":"deleting ManagedCluster","time":"2026-11-18T11:15:13.5611837Z","source":{"function":"github.com/Azure/ARO-HCP/mgmt-agent/pkg/controller/acmuninstall.(*Controller).ensureManagedClustersDeleted","file":"/app/mgmt-agent/pkg/controller/acmuninstall/controller.go","line":331},"controller_name":"acm-uninstall","sync":"acm-uninstall","managedcluster":"2u5j0t8jism1kso341ve6je2a8mqjtgi"}
    

    And eventually, moved on to doing the rest of the steps, up until all was done

    "timestamp": 2026-11-18T11:29:12.817Z,
    "log": {
    	"time": "2026-11-18T11:29:12.8173632Z",
    	"level": "INFO",
    	"source": {
    		"function": "github.com/Azure/ARO-HCP/mgmt-agent/pkg/controller/acmuninstall.(*Controller).reconcile",
    		"file": "/app/mgmt-agent/pkg/controller/acmuninstall/controller.go",
    		"line": 259
    	},
    	"msg": "ACM uninstall completed; all steps finished",
    	"controller_name": "acm-uninstall",
    	"sync": "acm-uninstall"
    }
    

    And for the new controller, the logs in https://dataexplorer.azure.com/clusters/hcp-dev-us-2.eastus2/databases/HostedControlPlaneLogs?query=H4sIAAAAAAAAA3WQzWrDMBCE732KRZfYUAnLJqEJ5A16S0%2B9lLW8OA76Q5JjAn34SiQ0vuS2zHy7M%2ByACXuMVG1OFK6Tok83xk0tsqqzqJxNOFkKdxnefmE5UyBQeo6JAjyACMxTiHyOS2fQ3rgZTWKAdgCLhqJHRT9lWi0UhONI9gFqN4riBqc1hTt9PAJDZbhbcod4njxXmtDOnv03SVO%2Bn9B46CktRBaqARMVuWJt0%2B64lFx%2BfEl5aJpDtxftfvvNaiFeUd2KqnOMD%2B5CKj2D3kvVbLgw5A%2F0t1UFjOoPFHPMP1IBAAA%3D shows exactly what steps were executed.

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: machi1990 Review duration: 1713m
    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 #8165"
    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