Warn instead of error on job cleanup failure
This prevents the Job from failing and running multiple times in the
case that a Backup/Snapshot was created successfully but only the
cleanup failed.
longhorn/longhorn#1424
@@ -213,9 +213,9 @@ func (job *Job) snapshotAndCleanup() error {
if done {
if len(errorList) != 0 {
for replica, errMsg := range errorList {
- logrus.Errorf("error purging snapshots on replica %v: %v", replica, errMsg)
+ logrus.Warnf("error purging snapshots on replica %v: %v", replica, errMsg)
}
- return errors.New("encountered one or more errors while purging snapshots")
+ logrus.Warnf("encountered one or more errors while purging snapshots")
}
return nil
}
@@ -341,10 +341,11 @@ func (job *Job) backupAndCleanup() (err error) {
cleanupBackupURLs := job.listBackupURLsForCleanup(backups)
for _, url := range cleanupBackupURLs {
if err := target.DeleteBackup(url); err != nil {
- return fmt.Errorf("Cleaned up backup %v failed for %v: %v", url, job.volumeName, err)
- }
+ logrus.Warnf("Cleaned up backup %v failed for %v: %v", url, job.volumeName, err)
+ } else {
logrus.Debugf("Cleaned up backup %v for %v", url, job.volumeName)
}
+ }
if err := manager.UpdateVolumeLastBackup(job.volumeName, target, job.GetVolume, job.UpdateVolumeStatus); err != nil {
logrus.Warnf("Failed to update volume LastBackup for %v: %v", job.volumeName, err)
}
