diff --git a/controller/controller.go b/controller/controller.go index 0878c51..64cf152 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -848,6 +848,12 @@ func (ctrl *ProvisionController) shouldProvision(claim *v1.PersistentVolumeClaim // shouldDelete returns whether a volume should have its backing volume // deleted, i.e. whether a Delete is "desired" func (ctrl *ProvisionController) shouldDelete(volume *v1.PersistentVolume) bool { + if qualifier, ok := ctrl.provisioner.(Qualifier); ok { + if !qualifier.ShouldDelete(volume) { + return false + } + } + // In 1.9+ PV protection means the object will exist briefly with a // deletion timestamp even after our successful Delete. Ignore it. if ctrl.kubeVersion.AtLeast(utilversion.MustParseSemantic("v1.9.0")) { diff --git a/controller/volume.go b/controller/volume.go index 92db410..5ce8e33 100644 --- a/controller/volume.go +++ b/controller/volume.go @@ -45,6 +45,9 @@ type Qualifier interface { // ShouldProvision returns whether provisioning for the claim should // be attempted. ShouldProvision(*v1.PersistentVolumeClaim) bool + + // ShouldDelete returns whether deleting the PV should be attempted. + ShouldDelete(volume *v1.PersistentVolume) bool } // BlockProvisioner is an optional interface implemented by provisioners to determine