support restoring/deleting legacy backups with .status.volumeBackups

Signed-off-by: Steve Kriss <steve@heptio.com>
This commit is contained in:
Steve Kriss
2018-10-19 12:54:24 -06:00
parent 6ef155ddff
commit 90d9be59d3
10 changed files with 589 additions and 166 deletions

View File

@@ -343,6 +343,26 @@ func (c *restoreController) validateAndComplete(restore *api.Restore, pluginMana
return backupInfo{}
}
// Ensure that we have either .status.volumeBackups (for pre-v0.10 backups) OR a
// volumesnapshots.json.gz file in obj storage (for v0.10+ backups), but not both.
// If we have .status.volumeBackups, ensure that there's only one volume snapshot
// location configured.
if info.backup.Status.VolumeBackups != nil {
snapshots, err := info.backupStore.GetBackupVolumeSnapshots(info.backup.Name)
if err != nil {
restore.Status.ValidationErrors = append(restore.Status.ValidationErrors, errors.Wrap(err, "Error checking for volumesnapshots file").Error())
} else if len(snapshots) > 0 {
restore.Status.ValidationErrors = append(restore.Status.ValidationErrors, "Backup must not have both .status.volumeBackups and a volumesnapshots.json.gz file in object storage")
} else {
locations, err := c.snapshotLocationLister.VolumeSnapshotLocations(restore.Namespace).List(labels.Everything())
if err != nil {
restore.Status.ValidationErrors = append(restore.Status.ValidationErrors, errors.Wrap(err, "Error listing volume snapshot locations").Error())
} else if len(locations) > 1 {
restore.Status.ValidationErrors = append(restore.Status.ValidationErrors, "Cannot restore backup with .status.volumeBackups when more than one volume snapshot location exists")
}
}
}
// Fill in the ScheduleName so it's easier to consume for metrics.
if restore.Spec.ScheduleName == "" {
restore.Spec.ScheduleName = info.backup.GetLabels()["ark-schedule"]