Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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