Skip to content

Commit

Permalink
Delete all PVCs if guest cluster is deleted in Rancher
Browse files Browse the repository at this point in the history
Signed-off-by: Volker Theile <[email protected]>
  • Loading branch information
votdev committed Oct 29, 2024
1 parent 03e510a commit 881b6eb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion harvester/harvester.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,16 @@ func (d *Driver) Remove() error {
}
return err
}

removeAll := false
if vm.Annotations["harvesterhci.io/removeAllPersistentVolumeClaims"] == "true" {
log.Debugf("Force the removal of all persistent volume claims")
removeAll = true
}

removedPVCs := make([]string, 0, len(vm.Spec.Template.Spec.Volumes))
for _, volume := range vm.Spec.Template.Spec.Volumes {
if volume.PersistentVolumeClaim == nil || volume.PersistentVolumeClaim.Hotpluggable {
if volume.PersistentVolumeClaim == nil || (!removeAll && volume.PersistentVolumeClaim.Hotpluggable) {
continue
}
removedPVCs = append(removedPVCs, volume.PersistentVolumeClaim.ClaimName)
Expand Down

0 comments on commit 881b6eb

Please sign in to comment.