Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a shouldDelete method in the provisioner Qualifer interface #3

Merged
merged 1 commit into from
Nov 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 deletionGuard, ok := ctrl.provisioner.(DeletionGuard); ok {
if !deletionGuard.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
7 changes: 7 additions & 0 deletions controller/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ type Qualifier interface {
ShouldProvision(*v1.PersistentVolumeClaim) bool
}

// DeletionGuard is an optional interface implemented by provisioners to determine
// whether a PV should be deleted.
type DeletionGuard interface {
// ShouldDelete returns whether deleting the PV should be attempted.
ShouldDelete(volume *v1.PersistentVolume) bool
wongma7 marked this conversation as resolved.
Show resolved Hide resolved
}

// BlockProvisioner is an optional interface implemented by provisioners to determine
// whether it supports block volume.
type BlockProvisioner interface {
Expand Down