Skip to content

Commit

Permalink
controller: Allow DR volume activation if the latest backup is empty
Browse files Browse the repository at this point in the history
Longhorn 7997

Signed-off-by: Shuo Wu <shuo.wu@suse.com>
  • Loading branch information
shuo-wu authored and innobead committed Feb 23, 2024
1 parent e05f7dd commit 54ea6c6
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions controller/volume_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -3120,15 +3120,19 @@ func (c *VolumeController) checkAndFinishVolumeRestore(v *longhorn.Volume, e *lo
return err
}
if bv != nil {
if !bv.Status.LastSyncedAt.IsZero() &&
bv.Spec.SyncRequestedAt.After(bv.Status.LastSyncedAt.Time) {
log.Infof("Restore/DR volume needs to wait for backup volume %s update", bvName)
return nil
}
if bv.Status.LastBackupName != e.Status.LastRestoredBackup {
log.Infof("Restore/DR volume needs to restore the latest backup %s, and the current restored backup is %s", bv.Status.LastBackupName, e.Status.LastRestoredBackup)
c.enqueueVolume(v)
return nil
if bv.Status.LastBackupName != "" {
// If the backup CR does not exist, the Longhorn system may be still syncing up the info with the remote backup target.
// If the backup is removed already, the backup volume should receive the notification and update bv.Status.LastBackupName.
// Hence we cannot continue the activation when the backup get call returns error IsNotFound.
b, err := c.ds.GetBackup(bv.Status.LastBackupName)
if err != nil {
return err
}
if b.Name != e.Status.LastRestoredBackup {
log.Infof("Restore/DR volume needs to restore the latest backup %s, and the current restored backup is %s", b.Name, e.Status.LastRestoredBackup)
c.enqueueVolume(v)
return nil
}
}
}
}
Expand Down

0 comments on commit 54ea6c6

Please sign in to comment.