Skip to content

Commit

Permalink
fix: rm unmanaged pvc before unintall (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
hysyeah authored Dec 4, 2024
1 parent 9c378b4 commit c6291b5
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions pkg/appinstaller/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,14 +630,6 @@ func (h *HelmOps) unregisterAppPerm() error {

// Uninstall do a uninstall operation for release.
func (h *HelmOps) Uninstall() error {
err := helm.UninstallCharts(h.actionConfig, h.app.AppName)
if err != nil {
return err
}
err = h.unregisterAppPerm()
if err != nil {
klog.Errorf("Failed to unregister app err=%v", err)
}
client, err := kubernetes.NewForConfig(h.kubeConfig)
if err != nil {
return err
Expand All @@ -649,10 +641,21 @@ func (h *HelmOps) Uninstall() error {
}
for _, pvc := range pvcs.Items {
err = client.CoreV1().PersistentVolumeClaims(pvc.Namespace).Delete(context.TODO(), pvc.Name, metav1.DeleteOptions{})
if err != nil {
if err != nil && !apierrors.IsNotFound(err) {
return err
}
}
}
err = helm.UninstallCharts(h.actionConfig, h.app.AppName)
if err != nil {
return err
}
err = h.unregisterAppPerm()
if err != nil {
klog.Errorf("Failed to unregister app err=%v", err)
}

if !utils.IsProtectedNamespace(h.app.Namespace) {
return client.CoreV1().Namespaces().Delete(context.TODO(), h.app.Namespace, metav1.DeleteOptions{})
}
return nil
Expand Down

0 comments on commit c6291b5

Please sign in to comment.