diff --git a/pkg/executor/common.go b/pkg/executor/common.go index b0a6e9922..40004ccda 100644 --- a/pkg/executor/common.go +++ b/pkg/executor/common.go @@ -607,7 +607,7 @@ func UpdateResourceBackupStatus( } // CreateVolumeBackup creates volumebackup CRD -func CreateVolumeBackup(name, namespace, repository, blName, blNamespace string) error { +func CreateVolumeBackup(name, namespace, repository, blName, blNamespace string) (bool, error) { new := &kdmpapi.VolumeBackup{ ObjectMeta: metav1.ObjectMeta{ Name: name, @@ -630,18 +630,21 @@ func CreateVolumeBackup(name, namespace, repository, blName, blNamespace string) if errors.IsNotFound(err) { _, err = kdmpops.Instance().CreateVolumeBackup(context.Background(), new) } - return err + return false, err } if !reflect.DeepEqual(vb.Spec, new.Spec) { - return fmt.Errorf("volumebackup %s/%s with different spec already exists", namespace, name) + return false, fmt.Errorf("volumebackup %s/%s with different spec already exists", namespace, name) } + // The Kopia snapshot is considered successful if the volume backup CR status is updated with the SnapshotID. + // In this case, we will mark the KDMP pod as successful without performing any further processing. if vb.Status.SnapshotID != "" { - return fmt.Errorf("volumebackup %s/%s with snapshot id already exists", namespace, name) + logrus.Infof("volumebackup %s/%s with snapshot id already exists", namespace, name) + return true, nil } - return nil + return false, nil } // GetSourcePath data source path diff --git a/pkg/executor/kopia/kopiabackup.go b/pkg/executor/kopia/kopiabackup.go index ea59d1a3c..40192a37c 100644 --- a/pkg/executor/kopia/kopiabackup.go +++ b/pkg/executor/kopia/kopiabackup.go @@ -89,7 +89,7 @@ func runBackup(sourcePath string) error { repo.Name = repoName } if volumeBackupName != "" { - if err := executor.CreateVolumeBackup( + if isSnapshotIDExists, err := executor.CreateVolumeBackup( volumeBackupName, bkpNamespace, repoName, @@ -98,6 +98,8 @@ func runBackup(sourcePath string) error { ); err != nil { logrus.Errorf("%s: %v", fn, err) return err + } else if isSnapshotIDExists { + return nil } } if rErr != nil { diff --git a/pkg/executor/restic/resticbackup.go b/pkg/executor/restic/resticbackup.go index 27c91643d..dc2942fd2 100644 --- a/pkg/executor/restic/resticbackup.go +++ b/pkg/executor/restic/resticbackup.go @@ -57,7 +57,7 @@ func runBackup(sourcePath string) error { } if volumeBackupName != "" { - if err = executor.CreateVolumeBackup( + if _, err = executor.CreateVolumeBackup( volumeBackupName, namespace, repo.Name,