From 79c6b55faef94d1a456cbfaeaa67f2d9f21dc89a Mon Sep 17 00:00:00 2001 From: Jian Qiu Date: Wed, 28 Sep 2022 10:05:36 +0800 Subject: [PATCH] Fix: delete addon crd at first (#277) This is to ensure manifestwork of addon is deleted at first. Signed-off-by: Jian Qiu Signed-off-by: Jian Qiu --- .../clustermanagercontroller/clustermanager_controller.go | 4 ++++ .../clustermanager_controller_test.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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()