diff --git a/pkg/operators/clustermanager/controllers/clustermanagercontroller/clustermanager_controller.go b/pkg/operators/clustermanager/controllers/clustermanagercontroller/clustermanager_controller.go index 8aca5418f..6dd2f13df 100644 --- a/pkg/operators/clustermanager/controllers/clustermanagercontroller/clustermanager_controller.go +++ b/pkg/operators/clustermanager/controllers/clustermanagercontroller/clustermanager_controller.go @@ -35,7 +35,11 @@ import ( ) var ( + // crdNames is the list of CRDs to be wiped out before deleting other resources when clusterManager is deleted. + // The order of the list matters, the managedclusteraddon crd needs to be deleted at first so all addon related + // manifestwork is deleted, then other manifestworks. crdNames = []string{ + "managedclusteraddons.addon.open-cluster-management.io", "manifestworks.work.open-cluster-management.io", "managedclusters.cluster.open-cluster-management.io", } diff --git a/pkg/operators/clustermanager/controllers/clustermanagercontroller/clustermanager_controller_test.go b/pkg/operators/clustermanager/controllers/clustermanagercontroller/clustermanager_controller_test.go index 5bf742c4b..ab4878c8b 100644 --- a/pkg/operators/clustermanager/controllers/clustermanagercontroller/clustermanager_controller_test.go +++ b/pkg/operators/clustermanager/controllers/clustermanagercontroller/clustermanager_controller_test.go @@ -222,7 +222,7 @@ func TestSyncDelete(t *testing.T) { } } // Check if resources are created as expected - testinghelper.AssertEqualNumber(t, len(deleteCRDActions), 12) + testinghelper.AssertEqualNumber(t, len(deleteCRDActions), 13) deleteAPIServiceActions := []clienttesting.DeleteActionImpl{} apiServiceActions := tc.apiRegistrationClient.Actions()