diff --git a/pkg/controller/core.oam.dev/v1alpha2/applicationconfiguration/render.go b/pkg/controller/core.oam.dev/v1alpha2/applicationconfiguration/render.go index 6dbe1f880..687eb7277 100644 --- a/pkg/controller/core.oam.dev/v1alpha2/applicationconfiguration/render.go +++ b/pkg/controller/core.oam.dev/v1alpha2/applicationconfiguration/render.go @@ -818,13 +818,13 @@ func isControlledByApp(ac *v1alpha2.ApplicationConfiguration) bool { return false } -// getOwnerFromAC will check and get the real owner, if the owner is Application, it will use Application as owner +// getOwnerFromAC will check and get the real owner, if the owner is Application, it will use ApplicationContext as owner // or it will make the AC as the owner func getOwnerFromAC(ac *v1alpha2.ApplicationConfiguration) *metav1.OwnerReference { for _, owner := range ac.GetOwnerReferences() { if owner.APIVersion == v1beta1.SchemeGroupVersion.String() && owner.Kind == v1beta1.ApplicationKind && owner.Controller != nil && *owner.Controller { - return &owner + return metav1.NewControllerRef(ac, v1alpha2.ApplicationContextGroupVersionKind) } } return metav1.NewControllerRef(ac, v1alpha2.ApplicationConfigurationGroupVersionKind) diff --git a/pkg/controller/core.oam.dev/v1alpha2/applicationcontext/applicationcontext_controller.go b/pkg/controller/core.oam.dev/v1alpha2/applicationcontext/applicationcontext_controller.go index 8b660b184..d36ccf55b 100644 --- a/pkg/controller/core.oam.dev/v1alpha2/applicationcontext/applicationcontext_controller.go +++ b/pkg/controller/core.oam.dev/v1alpha2/applicationcontext/applicationcontext_controller.go @@ -102,13 +102,6 @@ func (r *Reconciler) Reconcile(request reconcile.Request) (reconcile.Result, err // the name of the appConfig has to be the same as the appContext appConfig.Name = appContext.Name appConfig.UID = appContext.UID - for _, owner := range appContext.GetOwnerReferences() { - // if the appContext is created by Application, set the AppConfig UID to align with the application - if owner.Kind == v1beta1.ApplicationKind { - appConfig.UID = owner.UID - break - } - } appConfig.SetLabels(appContext.GetLabels()) appConfig.SetAnnotations(appContext.GetAnnotations()) // makes sure that the appConfig's owner is the same as the appContext diff --git a/pkg/oam/util/helper.go b/pkg/oam/util/helper.go index f1f3b406a..aa51493c4 100644 --- a/pkg/oam/util/helper.go +++ b/pkg/oam/util/helper.go @@ -152,7 +152,7 @@ func LocateParentAppConfig(ctx context.Context, client client.Client, oamObject } } if o.Kind == v1beta1.ApplicationKind { - var eventObj = &v1beta1.Application{} + var eventObj = &v1alpha2.ApplicationContext{} appName := o.Name if len(appName) > 0 { nn := types.NamespacedName{ diff --git a/test/e2e-test/app_resourcetracker_test.go b/test/e2e-test/app_resourcetracker_test.go index dfe22f758..2c40d53d4 100644 --- a/test/e2e-test/app_resourcetracker_test.go +++ b/test/e2e-test/app_resourcetracker_test.go @@ -241,7 +241,7 @@ var _ = Describe("Test application cross namespace resource", func() { return fmt.Errorf("error workload number %v", err) } workload := depolys.Items[0] - if len(workload.OwnerReferences) != 1 || workload.OwnerReferences[0].Kind != v1beta1.ApplicationKind { + if len(workload.OwnerReferences) != 1 || workload.OwnerReferences[0].Kind != v1alpha2.ApplicationContextKind { return fmt.Errorf("workload owneRefernece err") } err = k8sClient.Get(ctx, generateResourceTrackerKey(app.Namespace, app.Name), resourceTracker) @@ -486,7 +486,7 @@ var _ = Describe("Test application cross namespace resource", func() { return fmt.Errorf("failed generate same namespace workload") } sameDeplpoy := same.Items[0] - if len(sameDeplpoy.OwnerReferences) != 1 || sameDeplpoy.OwnerReferences[0].Kind != v1beta1.ApplicationKind { + if len(sameDeplpoy.OwnerReferences) != 1 || sameDeplpoy.OwnerReferences[0].Kind != v1alpha2.ApplicationContextKind { return fmt.Errorf("same ns deploy have error ownerReference") } err = k8sClient.List(ctx, cross, crossOpts...) @@ -539,7 +539,7 @@ var _ = Describe("Test application cross namespace resource", func() { return fmt.Errorf("failed generate same namespace workload") } sameDeplpoy := same.Items[0] - if len(sameDeplpoy.OwnerReferences) != 1 || sameDeplpoy.OwnerReferences[0].Kind != v1beta1.ApplicationKind { + if len(sameDeplpoy.OwnerReferences) != 1 || sameDeplpoy.OwnerReferences[0].Kind != v1alpha2.ApplicationContextKind { return fmt.Errorf("same ns deploy have error ownerReference") } err = k8sClient.List(ctx, cross, crossOpts...) diff --git a/test/e2e-test/rollout_plan_test.go b/test/e2e-test/rollout_plan_test.go index db8bfc59a..2bbbf9a74 100644 --- a/test/e2e-test/rollout_plan_test.go +++ b/test/e2e-test/rollout_plan_test.go @@ -182,7 +182,7 @@ var _ = Describe("Cloneset based rollout tests", func() { } return "" }, - time.Second*30, time.Millisecond*500).Should(BeEquivalentTo(v1beta1.ApplicationKind)) + time.Second*30, time.Millisecond*500).Should(BeEquivalentTo(v1alpha2.ApplicationContextKind)) Expect(clonesetOwner.Name).Should(BeEquivalentTo(targetAppName)) Expect(kc.Status.UpdatedReplicas).Should(BeEquivalentTo(*kc.Spec.Replicas)) Expect(kc.Status.UpdatedReadyReplicas).Should(BeEquivalentTo(*kc.Spec.Replicas))