Created
October 25, 2018 17:37
-
-
Save nrb/ec03b88e3150b50b48950f0118b8f038 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if groupResource == kuberesource.PersistentVolumes { | |
- _, found := ctx.backup.Status.VolumeBackups[name] | |
- reclaimPolicy, err := collections.GetString(obj.Object, "spec.persistentVolumeReclaimPolicy") | |
- if err == nil && !found && reclaimPolicy == "Delete" { | |
- ctx.log.Infof("Not restoring PV because it doesn't have a snapshot and its reclaim policy is Delete.") | |
+ var hasSnapshot bool | |
- ctx.pvsToProvision.Insert(name) | |
+ if len(ctx.backup.Status.VolumeBackups) > 0 { | |
+ // pre-v0.10 backup | |
+ _, hasSnapshot = ctx.backup.Status.VolumeBackups[name] | |
+ } else { | |
+ // v0.10+ backup | |
+ for _, snapshot := range ctx.volumeSnapshots { | |
+ if snapshot.Spec.PersistentVolumeName == name { | |
+ hasSnapshot = true | |
+ break | |
+ } | |
+ } | |
+ } | |
+ if !hasSnapshot && hasDeleteReclaimPolicy(obj.Object) { | |
+ ctx.log.Infof("Not restoring PV because it doesn't have a snapshot and its reclaim policy is Delete.") | |
+ ctx.pvsToProvision.Insert(name) | |
continue | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment