Skip to content
This repository has been archived by the owner on Oct 21, 2020. It is now read-only.

Commit

Permalink
Add a shouldDelete method in the provisioner Qualifer interface
Browse files Browse the repository at this point in the history
  • Loading branch information
jian-he committed Nov 2, 2018
1 parent c892be7 commit 331142a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,13 @@ 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")) {
Expand Down
3 changes: 3 additions & 0 deletions lib/controller/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 331142a

Please sign in to comment.