Skip to content

Instantly share code, notes, and snippets.

@nrb
Created October 25, 2018 17:37
Show Gist options
  • Save nrb/ec03b88e3150b50b48950f0118b8f038 to your computer and use it in GitHub Desktop.
Save nrb/ec03b88e3150b50b48950f0118b8f038 to your computer and use it in GitHub Desktop.
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