From 7caafd5cf2fc4765a8a38dfd3350ee4463cb0ad2 Mon Sep 17 00:00:00 2001 From: haoqing0110 Date: Thu, 14 Mar 2024 09:43:01 +0000 Subject: [PATCH] addon ownerref to pass integration tests Signed-off-by: haoqing0110 --- cmd/example/helloworld/main.go | 1 - pkg/addonfactory/addonfactory.go | 18 +---- pkg/agent/inteface.go | 73 ------------------- test/integration/agent_deploy_test.go | 20 ++--- test/integration/agent_hook_deploy_test.go | 9 ++- test/integration/agent_hosting_deploy_test.go | 13 ++-- .../agent_hosting_hook_deploy_test.go | 9 +-- test/integration/assertion_test.go | 16 ++++ .../cluster_management_addon_test.go | 7 +- test/integration/multiworks_test.go | 11 ++- test/integration/registration_test.go | 11 ++- test/integration/suite_test.go | 7 -- 12 files changed, 53 insertions(+), 142 deletions(-) diff --git a/cmd/example/helloworld/main.go b/cmd/example/helloworld/main.go index 805af2e5c..7e66cc56e 100644 --- a/cmd/example/helloworld/main.go +++ b/cmd/example/helloworld/main.go @@ -108,7 +108,6 @@ func runController(ctx context.Context, kubeConfig *rest.Config) error { ), ). WithAgentRegistrationOption(registrationOption). - // WithInstallStrategy(addonagent.InstallAllStrategy(helloworld.InstallationNamespace)). WithAgentHealthProber(helloworld.AgentHealthProber()). BuildTemplateAgentAddon() if err != nil { diff --git a/pkg/addonfactory/addonfactory.go b/pkg/addonfactory/addonfactory.go index b49a0a31d..32caa9ba8 100644 --- a/pkg/addonfactory/addonfactory.go +++ b/pkg/addonfactory/addonfactory.go @@ -51,9 +51,8 @@ func NewAgentAddonFactory(addonName string, fs embed.FS, dir string) *AgentAddon fs: fs, dir: dir, agentAddonOptions: agent.AgentAddonOptions{ - AddonName: addonName, - Registration: nil, - // InstallStrategy: nil, + AddonName: addonName, + Registration: nil, HealthProber: nil, SupportedConfigGVRs: []schema.GroupVersionResource{}, }, @@ -78,19 +77,6 @@ func (f *AgentAddonFactory) WithGetValuesFuncs(getValuesFuncs ...GetValuesFunc) return f } -// WithInstallStrategy defines the installation strategy of the manifests prescribed by Manifests(..). -// Deprecated: add annotation "addon.open-cluster-management.io/lifecycle: addon-manager" to ClusterManagementAddon -// and define install strategy in ClusterManagementAddon spec.installStrategy instead. -// The migration plan refer to https://github.com/open-cluster-management-io/ocm/issues/355. -/*func (f *AgentAddonFactory) WithInstallStrategy(strategy *agent.InstallStrategy) *AgentAddonFactory { - if strategy.InstallNamespace == "" { - strategy.InstallNamespace = AddonDefaultInstallNamespace - } - f.agentAddonOptions.InstallStrategy = strategy - - return f -}*/ - // WithAgentRegistrationOption defines how agent is registered to the hub cluster. func (f *AgentAddonFactory) WithAgentRegistrationOption(option *agent.RegistrationOption) *AgentAddonFactory { f.agentAddonOptions.Registration = option diff --git a/pkg/agent/inteface.go b/pkg/agent/inteface.go index 03890f198..3229237b0 100644 --- a/pkg/agent/inteface.go +++ b/pkg/agent/inteface.go @@ -46,14 +46,6 @@ type AgentAddonOptions struct { // +optional Registration *RegistrationOption - // InstallStrategy defines that addon should be created in which clusters. - // Addon will not be installed automatically until a ManagedClusterAddon is applied to the cluster's - // namespace if InstallStrategy is nil. - // Deprecated: use installStrategy config in ClusterManagementAddOn API instead - // The migration plan refer to https://github.com/open-cluster-management-io/ocm/issues/355. - // +optional - // InstallStrategy *InstallStrategy - // Updaters select a set of resources and define the strategies to update them. // UpdateStrategy is Update if no Updater is defined for a resource. // +optional @@ -154,23 +146,6 @@ type RegistrationOption struct { CSRSign CSRSignerFunc } -// InstallStrategy is the installation strategy of the manifests prescribed by Manifests(..). -// type InstallStrategy struct { -// *installStrategy -// } - -// type installStrategy struct { -// // InstallNamespace is target deploying namespace in the managed cluster upon automatic addon installation. -// InstallNamespace string -// -// // managedClusterFilter will filter the clusters to install the addon to. -// managedClusterFilter func(cluster *clusterv1.ManagedCluster) bool -// } - -// func (s *InstallStrategy) GetManagedClusterFilter() func(cluster *clusterv1.ManagedCluster) bool { -// return s.managedClusterFilter -// } - type Updater struct { // ResourceIdentifier sets what resources the strategy applies to ResourceIdentifier workapiv1.ResourceIdentifier @@ -255,54 +230,6 @@ func DefaultGroups(clusterName, addonName string) []string { } } -// // InstallAllStrategy indicate to install addon to all clusters -// func InstallAllStrategy(installNamespace string) *InstallStrategy { -// return &InstallStrategy{ -// &installStrategy{ -// InstallNamespace: installNamespace, -// managedClusterFilter: func(cluster *clusterv1.ManagedCluster) bool { -// return true -// }, -// }, -// } -// } - -// InstallByLabelStrategy indicate to install addon based on clusters' label -// func InstallByLabelStrategy(installNamespace string, selector metav1.LabelSelector) *InstallStrategy { -// return &InstallStrategy{ -// &installStrategy{ -// InstallNamespace: installNamespace, -// managedClusterFilter: func(cluster *clusterv1.ManagedCluster) bool { -// selector, err := metav1.LabelSelectorAsSelector(&selector) -// if err != nil { -// klog.Warningf("labels selector is not correct: %v", err) -// return false -// } -// -// if !selector.Matches(labels.Set(cluster.Labels)) { -// return false -// } -// return true -// }, -// }, -// } -// } - -// InstallByFilterFunctionStrategy indicate to install addon based on a filter function, and it will also install addons if the filter function is nil. -// func InstallByFilterFunctionStrategy(installNamespace string, f func(cluster *clusterv1.ManagedCluster) bool) *InstallStrategy { -// if f == nil { -// f = func(cluster *clusterv1.ManagedCluster) bool { -// return true -// } -// } -// return &InstallStrategy{ -// &installStrategy{ -// InstallNamespace: installNamespace, -// managedClusterFilter: f, -// }, -// } -// } - // ApprovalAllCSRs returns true for all csrs. func ApprovalAllCSRs(cluster *clusterv1.ManagedCluster, addon *addonapiv1alpha1.ManagedClusterAddOn, csr *certificatesv1.CertificateSigningRequest) bool { return true diff --git a/test/integration/agent_deploy_test.go b/test/integration/agent_deploy_test.go index 9eedbd9a9..a02d40185 100644 --- a/test/integration/agent_deploy_test.go +++ b/test/integration/agent_deploy_test.go @@ -120,6 +120,7 @@ var _ = ginkgo.Describe("Agent deploy", func() { var managedClusterName string var err error var manifestWorkName string + var cma *addonapiv1alpha1.ClusterManagementAddOn ginkgo.BeforeEach(func() { suffix := rand.String(5) managedClusterName = fmt.Sprintf("managedcluster-%s", suffix) @@ -140,8 +141,8 @@ var _ = ginkgo.Describe("Agent deploy", func() { _, err = hubKubeClient.CoreV1().Namespaces().Create(context.Background(), ns, metav1.CreateOptions{}) gomega.Expect(err).ToNot(gomega.HaveOccurred()) - cma := newClusterManagementAddon(testAddonImpl.name) - _, err = hubAddonClient.AddonV1alpha1().ClusterManagementAddOns().Create(context.Background(), + cma = newClusterManagementAddon(testAddonImpl.name) + cma, err = hubAddonClient.AddonV1alpha1().ClusterManagementAddOns().Create(context.Background(), cma, metav1.CreateOptions{}) gomega.Expect(err).ToNot(gomega.HaveOccurred()) @@ -175,8 +176,7 @@ var _ = ginkgo.Describe("Agent deploy", func() { InstallNamespace: "default", }, } - _, err = hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(managedClusterName).Create(context.Background(), addon, metav1.CreateOptions{}) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) + createManagedClusterAddOnwithOwnerRefs(managedClusterName, addon, cma) gomega.Eventually(func() error { work, err := hubWorkClient.WorkV1().ManifestWorks(managedClusterName).Get(context.Background(), manifestWorkName, metav1.GetOptions{}) @@ -270,8 +270,7 @@ var _ = ginkgo.Describe("Agent deploy", func() { InstallNamespace: "default", }, } - _, err = hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(managedClusterName).Create(context.Background(), addon, metav1.CreateOptions{}) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) + createManagedClusterAddOnwithOwnerRefs(managedClusterName, addon, cma) gomega.Eventually(func() error { work, err := hubWorkClient.WorkV1().ManifestWorks(managedClusterName).Get(context.Background(), manifestWorkName, metav1.GetOptions{}) @@ -422,8 +421,7 @@ var _ = ginkgo.Describe("Agent deploy", func() { InstallNamespace: "default", }, } - _, err = hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(managedClusterName).Create(context.Background(), addon, metav1.CreateOptions{}) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) + createManagedClusterAddOnwithOwnerRefs(managedClusterName, addon, cma) gomega.Eventually(func() error { work, err := hubWorkClient.WorkV1().ManifestWorks(managedClusterName).Get(context.Background(), manifestWorkName, metav1.GetOptions{}) @@ -571,8 +569,7 @@ var _ = ginkgo.Describe("Agent deploy", func() { InstallNamespace: "default", }, } - _, err = hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(managedClusterName).Create(context.Background(), addon, metav1.CreateOptions{}) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) + createManagedClusterAddOnwithOwnerRefs(managedClusterName, addon, cma) gomega.Eventually(func() error { work, err := hubWorkClient.WorkV1().ManifestWorks(managedClusterName).Get(context.Background(), manifestWorkName, metav1.GetOptions{}) @@ -637,8 +634,7 @@ var _ = ginkgo.Describe("Agent deploy", func() { InstallNamespace: "default", }, } - _, err = hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(managedClusterName).Create(context.Background(), addon, metav1.CreateOptions{}) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) + createManagedClusterAddOnwithOwnerRefs(managedClusterName, addon, cma) var work *workapiv1.ManifestWork gomega.Eventually(func() error { diff --git a/test/integration/agent_hook_deploy_test.go b/test/integration/agent_hook_deploy_test.go index 1b4dd449e..809a3891b 100644 --- a/test/integration/agent_hook_deploy_test.go +++ b/test/integration/agent_hook_deploy_test.go @@ -72,6 +72,7 @@ var jobCompleteValue = "True" var _ = ginkgo.Describe("Agent hook deploy", func() { var managedClusterName string + var cma *addonapiv1alpha1.ClusterManagementAddOn var err error ginkgo.BeforeEach(func() { @@ -93,8 +94,8 @@ var _ = ginkgo.Describe("Agent hook deploy", func() { _, err = hubKubeClient.CoreV1().Namespaces().Create(context.Background(), ns, metav1.CreateOptions{}) gomega.Expect(err).ToNot(gomega.HaveOccurred()) - cma := newClusterManagementAddon(testAddonImpl.name) - _, err = hubAddonClient.AddonV1alpha1().ClusterManagementAddOns().Create(context.Background(), + cma = newClusterManagementAddon(testAddonImpl.name) + cma, err = hubAddonClient.AddonV1alpha1().ClusterManagementAddOns().Create(context.Background(), cma, metav1.CreateOptions{}) gomega.Expect(err).ToNot(gomega.HaveOccurred()) }) @@ -126,8 +127,8 @@ var _ = ginkgo.Describe("Agent hook deploy", func() { InstallNamespace: "default", }, } - _, err = hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(managedClusterName).Create(context.Background(), addon, metav1.CreateOptions{}) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) + createManagedClusterAddOnwithOwnerRefs(managedClusterName, addon, cma) + // deploy manifest is deployed gomega.Eventually(func() error { work, err := hubWorkClient.WorkV1().ManifestWorks(managedClusterName).Get(context.Background(), fmt.Sprintf("addon-%s-deploy-0", testAddonImpl.name), metav1.GetOptions{}) diff --git a/test/integration/agent_hosting_deploy_test.go b/test/integration/agent_hosting_deploy_test.go index cf2587afe..6b22aba59 100644 --- a/test/integration/agent_hosting_deploy_test.go +++ b/test/integration/agent_hosting_deploy_test.go @@ -72,6 +72,7 @@ var _ = ginkgo.Describe("Agent deploy", func() { var managedClusterName, hostingClusterName string var err error var hostingManifestWorkName string + var cma *addonapiv1alpha1.ClusterManagementAddOn ginkgo.BeforeEach(func() { suffix := rand.String(5) managedClusterName = fmt.Sprintf("managedcluster-%s", suffix) @@ -110,8 +111,8 @@ var _ = ginkgo.Describe("Agent deploy", func() { _, err = hubKubeClient.CoreV1().Namespaces().Create(context.Background(), ns, metav1.CreateOptions{}) gomega.Expect(err).ToNot(gomega.HaveOccurred()) - cma := newClusterManagementAddon(testHostedAddonImpl.name) - _, err = hubAddonClient.AddonV1alpha1().ClusterManagementAddOns().Create(context.Background(), + cma = newClusterManagementAddon(testHostedAddonImpl.name) + cma, err = hubAddonClient.AddonV1alpha1().ClusterManagementAddOns().Create(context.Background(), cma, metav1.CreateOptions{}) gomega.Expect(err).ToNot(gomega.HaveOccurred()) }) @@ -156,9 +157,7 @@ var _ = ginkgo.Describe("Agent deploy", func() { InstallNamespace: "default", }, } - _, err = hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(managedClusterName).Create( - context.Background(), addon, metav1.CreateOptions{}) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) + createManagedClusterAddOnwithOwnerRefs(managedClusterName, addon, cma) gomega.Eventually(func() error { work, err := hubWorkClient.WorkV1().ManifestWorks(hostingClusterName).Get(context.Background(), @@ -278,9 +277,7 @@ var _ = ginkgo.Describe("Agent deploy", func() { InstallNamespace: "default", }, } - _, err = hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(managedClusterName).Create( - context.Background(), addon, metav1.CreateOptions{}) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) + createManagedClusterAddOnwithOwnerRefs(managedClusterName, addon, cma) gomega.Eventually(func() error { work, err := hubWorkClient.WorkV1().ManifestWorks(hostingClusterName).Get(context.Background(), diff --git a/test/integration/agent_hosting_hook_deploy_test.go b/test/integration/agent_hosting_hook_deploy_test.go index cda0507a5..afbd9a0d1 100644 --- a/test/integration/agent_hosting_hook_deploy_test.go +++ b/test/integration/agent_hosting_hook_deploy_test.go @@ -75,6 +75,7 @@ var _ = ginkgo.Describe("Agent hook deploy", func() { var err error var hostingManifestWorkName string var hostingJobCompleteValue = "True" + var cma *addonapiv1alpha1.ClusterManagementAddOn ginkgo.BeforeEach(func() { suffix := rand.String(5) managedClusterName = fmt.Sprintf("managedcluster-%s", suffix) @@ -113,8 +114,8 @@ var _ = ginkgo.Describe("Agent hook deploy", func() { _, err = hubKubeClient.CoreV1().Namespaces().Create(context.Background(), ns, metav1.CreateOptions{}) gomega.Expect(err).ToNot(gomega.HaveOccurred()) - cma := newClusterManagementAddon(testHostedAddonImpl.name) - _, err = hubAddonClient.AddonV1alpha1().ClusterManagementAddOns().Create(context.Background(), + cma = newClusterManagementAddon(testHostedAddonImpl.name) + cma, err = hubAddonClient.AddonV1alpha1().ClusterManagementAddOns().Create(context.Background(), cma, metav1.CreateOptions{}) gomega.Expect(err).ToNot(gomega.HaveOccurred()) }) @@ -163,9 +164,7 @@ var _ = ginkgo.Describe("Agent hook deploy", func() { InstallNamespace: "default", }, } - _, err = hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(managedClusterName).Create( - context.Background(), addon, metav1.CreateOptions{}) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) + createManagedClusterAddOnwithOwnerRefs(managedClusterName, addon, cma) gomega.Eventually(func() error { work, err := hubWorkClient.WorkV1().ManifestWorks(hostingClusterName).Get(context.Background(), diff --git a/test/integration/assertion_test.go b/test/integration/assertion_test.go index 14fa1189f..ee7b99b78 100644 --- a/test/integration/assertion_test.go +++ b/test/integration/assertion_test.go @@ -12,6 +12,7 @@ import ( "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "open-cluster-management.io/addon-framework/pkg/utils" addonapiv1alpha1 "open-cluster-management.io/api/addon/v1alpha1" ) @@ -102,6 +103,21 @@ func updateClusterManagementAddOn(ctx context.Context, new *addonapiv1alpha1.Clu }, eventuallyTimeout, eventuallyInterval).Should(gomega.BeTrue()) } +func createManagedClusterAddOnwithOwnerRefs(namespace string, addon *addonapiv1alpha1.ManagedClusterAddOn, cma *addonapiv1alpha1.ClusterManagementAddOn) { + addon, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(namespace).Create(context.Background(), addon, metav1.CreateOptions{}) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + + addonCopy := addon.DeepCopy() + + // This is to assume that addon-manager has already added the OwnerReferences. + owner := metav1.NewControllerRef(cma, addonapiv1alpha1.GroupVersion.WithKind("ClusterManagementAddOn")) + modified := utils.MergeOwnerRefs(&addonCopy.OwnerReferences, *owner, false) + if modified { + _, err = hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(addonCopy.Namespace).Update(context.Background(), addonCopy, metav1.UpdateOptions{}) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + } +} + func updateManagedClusterAddOnStatus(ctx context.Context, new *addonapiv1alpha1.ManagedClusterAddOn) { gomega.Eventually(func() bool { old, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(new.Namespace).Get(context.Background(), new.Name, metav1.GetOptions{}) diff --git a/test/integration/cluster_management_addon_test.go b/test/integration/cluster_management_addon_test.go index 4fd737582..2658655ee 100644 --- a/test/integration/cluster_management_addon_test.go +++ b/test/integration/cluster_management_addon_test.go @@ -57,7 +57,7 @@ var _ = ginkgo.Describe("ClusterManagementAddon", func() { ginkgo.It("Should update config related object successfully", func() { // Create clustermanagement addon - clusterManagementAddon := &addonapiv1alpha1.ClusterManagementAddOn{ + cma := &addonapiv1alpha1.ClusterManagementAddOn{ ObjectMeta: metav1.ObjectMeta{ Name: testAddonImpl.name, }, @@ -67,7 +67,7 @@ var _ = ginkgo.Describe("ClusterManagementAddon", func() { }, }, } - _, err = hubAddonClient.AddonV1alpha1().ClusterManagementAddOns().Create(context.Background(), clusterManagementAddon, metav1.CreateOptions{}) + cma, err := hubAddonClient.AddonV1alpha1().ClusterManagementAddOns().Create(context.Background(), cma, metav1.CreateOptions{}) gomega.Expect(err).ToNot(gomega.HaveOccurred()) // Create managed cluster addon @@ -79,8 +79,7 @@ var _ = ginkgo.Describe("ClusterManagementAddon", func() { InstallNamespace: "test", }, } - _, err = hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(managedClusterName).Create(context.Background(), addon, metav1.CreateOptions{}) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) + createManagedClusterAddOnwithOwnerRefs(managedClusterName, addon, cma) gomega.Eventually(func() error { actual, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(managedClusterName).Get(context.Background(), testAddonImpl.name, metav1.GetOptions{}) diff --git a/test/integration/multiworks_test.go b/test/integration/multiworks_test.go index c939dac3b..293cfeb50 100644 --- a/test/integration/multiworks_test.go +++ b/test/integration/multiworks_test.go @@ -93,6 +93,7 @@ var _ = ginkgo.Describe("Agent deploy multi works", func() { var managedClusterName string var err error var manifestWorkName0, manifestWorkName1 string + var cma *addonapiv1alpha1.ClusterManagementAddOn ginkgo.BeforeEach(func() { suffix := rand.String(5) managedClusterName = fmt.Sprintf("managedcluster-%s", suffix) @@ -113,8 +114,8 @@ var _ = ginkgo.Describe("Agent deploy multi works", func() { _, err = hubKubeClient.CoreV1().Namespaces().Create(context.Background(), ns, metav1.CreateOptions{}) gomega.Expect(err).ToNot(gomega.HaveOccurred()) - cma := newClusterManagementAddon(testMultiWorksAddonImpl.name) - _, err = hubAddonClient.AddonV1alpha1().ClusterManagementAddOns().Create(context.Background(), + cma = newClusterManagementAddon(testMultiWorksAddonImpl.name) + cma, err = hubAddonClient.AddonV1alpha1().ClusterManagementAddOns().Create(context.Background(), cma, metav1.CreateOptions{}) gomega.Expect(err).ToNot(gomega.HaveOccurred()) }) @@ -157,8 +158,7 @@ var _ = ginkgo.Describe("Agent deploy multi works", func() { InstallNamespace: "default", }, } - _, err = hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(managedClusterName).Create(context.Background(), addon, metav1.CreateOptions{}) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) + createManagedClusterAddOnwithOwnerRefs(managedClusterName, addon, cma) gomega.Eventually(func() error { works, err := hubWorkClient.WorkV1().ManifestWorks(managedClusterName).List(context.Background(), metav1.ListOptions{ @@ -347,8 +347,7 @@ var _ = ginkgo.Describe("Agent deploy multi works", func() { InstallNamespace: "default", }, } - _, err = hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(managedClusterName).Create(context.Background(), addon, metav1.CreateOptions{}) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) + createManagedClusterAddOnwithOwnerRefs(managedClusterName, addon, cma) gomega.Eventually(func() error { works, err := hubWorkClient.WorkV1().ManifestWorks(managedClusterName).List(context.Background(), metav1.ListOptions{ diff --git a/test/integration/registration_test.go b/test/integration/registration_test.go index 18eaa9add..a243defc4 100644 --- a/test/integration/registration_test.go +++ b/test/integration/registration_test.go @@ -18,6 +18,7 @@ import ( var _ = ginkgo.Describe("Addon Registration", func() { var managedClusterName string + var cma *addonapiv1alpha1.ClusterManagementAddOn var err error ginkgo.BeforeEach(func() { @@ -40,7 +41,7 @@ var _ = ginkgo.Describe("Addon Registration", func() { gomega.Expect(err).ToNot(gomega.HaveOccurred()) // Create clustermanagement addon - clusterManagementAddon := &addonapiv1alpha1.ClusterManagementAddOn{ + cma = &addonapiv1alpha1.ClusterManagementAddOn{ ObjectMeta: metav1.ObjectMeta{ Name: testAddonImpl.name, }, @@ -50,7 +51,7 @@ var _ = ginkgo.Describe("Addon Registration", func() { }, }, } - _, err = hubAddonClient.AddonV1alpha1().ClusterManagementAddOns().Create(context.Background(), clusterManagementAddon, metav1.CreateOptions{}) + cma, err = hubAddonClient.AddonV1alpha1().ClusterManagementAddOns().Create(context.Background(), cma, metav1.CreateOptions{}) gomega.Expect(err).ToNot(gomega.HaveOccurred()) }) @@ -79,8 +80,7 @@ var _ = ginkgo.Describe("Addon Registration", func() { InstallNamespace: "test", }, } - _, err = hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(managedClusterName).Create(context.Background(), addon, metav1.CreateOptions{}) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) + createManagedClusterAddOnwithOwnerRefs(managedClusterName, addon, cma) gomega.Eventually(func() error { actual, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(managedClusterName).Get(context.Background(), testAddonImpl.name, metav1.GetOptions{}) @@ -112,8 +112,7 @@ var _ = ginkgo.Describe("Addon Registration", func() { InstallNamespace: "test", }, } - _, err = hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(managedClusterName).Create(context.Background(), addon, metav1.CreateOptions{}) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) + createManagedClusterAddOnwithOwnerRefs(managedClusterName, addon, cma) gomega.Eventually(func() error { actual, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(managedClusterName).Get(context.Background(), testAddonImpl.name, metav1.GetOptions{}) diff --git a/test/integration/suite_test.go b/test/integration/suite_test.go index 73a9b7aaf..806ebfc7a 100644 --- a/test/integration/suite_test.go +++ b/test/integration/suite_test.go @@ -97,11 +97,6 @@ var _ = ginkgo.BeforeSuite(func(done ginkgo.Done) { name: "test-install-all", manifests: map[string][]runtime.Object{}, registrations: map[string][]addonapiv1alpha1.RegistrationConfig{}, - // installStrategy: agent.InstallByLabelStrategy("default", v1.LabelSelector{ - // MatchLabels: map[string]string{ - // "test": "test", - // }, - // }), } testMultiWorksAddonImpl = &testAddon{ @@ -145,7 +140,6 @@ type testAddon struct { approveCSR bool cert []byte prober *agent.HealthProber - // installStrategy *agent.InstallStrategy hostedModeEnabled bool supportedConfigGVRs []schema.GroupVersionResource } @@ -158,7 +152,6 @@ func (t *testAddon) GetAgentAddonOptions() agent.AgentAddonOptions { option := agent.AgentAddonOptions{ AddonName: t.name, HealthProber: t.prober, - // InstallStrategy: t.installStrategy, HostedModeEnabled: t.hostedModeEnabled, SupportedConfigGVRs: t.supportedConfigGVRs, }