Skip to content

Commit

Permalink
remove not found error (#453)
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaByte875 authored Feb 26, 2024
1 parent 4263bf1 commit baf11b4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
48 changes: 23 additions & 25 deletions pkg/controller/nebularestore/nebula_restore_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package nebularestore

import (
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/klog/v2"

"github.com/vesoft-inc/nebula-operator/apis/apps/v1alpha1"
Expand Down Expand Up @@ -99,34 +98,33 @@ func (c *defaultRestoreControl) UpdateNebulaRestore(nr *v1alpha1.NebulaRestore)
}
}

err := c.restoreManager.Sync(nr)
if err != nil && !utilerrors.IsReconcileError(err) {
if apierrors.IsNotFound(err) {
return nil
}
if err := c.clientSet.NebulaRestore().UpdateNebulaRestoreStatus(nr, &v1alpha1.RestoreCondition{
Type: v1alpha1.RestoreFailed,
Status: corev1.ConditionTrue,
Reason: "ExecuteFailed",
Message: err.Error(),
}, &kube.RestoreUpdateStatus{
ConditionType: v1alpha1.RestoreFailed,
}); err != nil {
klog.Errorf("Fail to update the condition of NebulaRestore [%s/%s], %v", ns, name, err)
}
updated, err := c.clientSet.NebulaRestore().GetNebulaRestore(ns, nr.Name)
if err != nil {
klog.Errorf("Fail to get NebulaRestore [%s/%s], %v", ns, name, err)
}
if nr.Spec.AutoRemoveFailed {
if err := c.deleteRestoredCluster(ns, updated.Status.ClusterName); err != nil {
klog.Errorf("Fail to delete NebulaCluster %v", err)
if err := c.restoreManager.Sync(nr); err != nil {
if !utilerrors.IsReconcileError(err) {
if err := c.clientSet.NebulaRestore().UpdateNebulaRestoreStatus(nr, &v1alpha1.RestoreCondition{
Type: v1alpha1.RestoreFailed,
Status: corev1.ConditionTrue,
Reason: "ExecuteFailed",
Message: err.Error(),
}, &kube.RestoreUpdateStatus{
ConditionType: v1alpha1.RestoreFailed,
}); err != nil {
klog.Errorf("Fail to update the condition of NebulaRestore [%s/%s], %v", ns, name, err)
}
updated, err := c.clientSet.NebulaRestore().GetNebulaRestore(ns, nr.Name)
if err != nil {
klog.Errorf("Fail to get NebulaRestore [%s/%s], %v", ns, name, err)
}
if nr.Spec.AutoRemoveFailed {
if err := c.deleteRestoredCluster(ns, updated.Status.ClusterName); err != nil {
klog.Errorf("Fail to delete NebulaCluster %v", err)
}
}
return nil
}
return nil
return err
}

return err
return nil
}

func (c *defaultRestoreControl) deleteRestoredCluster(namespace, ncName string) error {
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/nebularestore/nebula_restore_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func (rm *restoreManager) syncRestoreProcess(nr *v1alpha1.NebulaRestore) error {
}
original, err := rm.clientSet.NebulaCluster().GetNebulaCluster(ns, originalName)
if err != nil {
klog.Errorf("backup cluster [%s/%s] not found", ns, originalName)
return err
}

Expand Down

0 comments on commit baf11b4

Please sign in to comment.