Skip to content

Commit

Permalink
feat: fix appinstance derived resoruce residue
Browse files Browse the repository at this point in the history
Signed-off-by: richardli1598 <opennaslab@gmail.com>
  • Loading branch information
richardli1598 committed Apr 21, 2024
1 parent b15377e commit 57d7ca7
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions pkg/controller/appinstance/appinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}

Expand Down

0 comments on commit 57d7ca7

Please sign in to comment.