From 57d7ca7b760553c71527bca4d1b2bc7e4dad3951 Mon Sep 17 00:00:00 2001 From: richardli1598 Date: Sun, 21 Apr 2024 17:35:35 +0800 Subject: [PATCH] feat: fix appinstance derived resoruce residue Signed-off-by: richardli1598 --- pkg/controller/appinstance/appinstance.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pkg/controller/appinstance/appinstance.go b/pkg/controller/appinstance/appinstance.go index 9213541..e3a293a 100644 --- a/pkg/controller/appinstance/appinstance.go +++ b/pkg/controller/appinstance/appinstance.go @@ -96,14 +96,6 @@ func (ac *AppInstanceController) Reconcile(resourceKey pkgtypes.NamespacedName) return ac.deleteAppInstanceResources(appIns) } - appIns.Finalizers = []string{utils.AppInstanceControllerFinalizerKey} - appIns, err = ac.openappClient.AppV1alpha1().AppInstances(appIns.Namespace). - Update(context.Background(), appIns, metav1.UpdateOptions{}) - if err != nil { - klog.Errorf("Failed to update app instance: %v", err) - return err - } - appTemplate := appIns.Spec.AppTemplate if appTemplate == "" { klog.Errorf("AppTemplate is empty in AppInstance(%s/%s)", appIns.Namespace, appIns.Name) @@ -117,14 +109,23 @@ func (ac *AppInstanceController) Reconcile(resourceKey pkgtypes.NamespacedName) return err } } + appIns.Status.DerivedResources = derivedResoruce - _, err = ac.openappClient.AppV1alpha1().AppInstances(appIns.Namespace). + appIns, err = ac.openappClient.AppV1alpha1().AppInstances(appIns.Namespace). UpdateStatus(context.Background(), appIns, metav1.UpdateOptions{}) if err != nil { klog.Errorf("Failed to update app instance status: %v", err) return err } + appIns.Finalizers = []string{utils.AppInstanceControllerFinalizerKey} + _, err = ac.openappClient.AppV1alpha1().AppInstances(appIns.Namespace). + Update(context.Background(), appIns, metav1.UpdateOptions{}) + if err != nil { + klog.Errorf("Failed to update app instance: %v", err) + return err + } + return nil }