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

Handle deletion of CSI migrated volumes #273

Merged
merged 1 commit into from
May 7, 2019
Merged
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
23 changes: 20 additions & 3 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -648,12 +648,29 @@ func (p *csiProvisioner) getVolumeContentSource(options controller.VolumeOptions
}

func (p *csiProvisioner) Delete(volume *v1.PersistentVolume) error {
if volume == nil || volume.Spec.CSI == nil {
if volume == nil {
return fmt.Errorf("invalid CSI PV")
}

var err error
if csitranslationlib.IsPVMigratable(volume) {
// we end up here only if CSI migration is enabled in-tree (both overall
// and for the specific plugin that is migratable) causing in-tree PV
// controller to yield deletion of PVs with in-tree source to external provisioner
// based on AnnDynamicallyProvisioned annotation.
volume, err = csitranslationlib.TranslateInTreePVToCSI(volume)
if err != nil {
return err
}
}

if volume.Spec.CSI == nil {
return fmt.Errorf("invalid CSI PV")
}

volumeId := p.volumeHandleToId(volume.Spec.CSI.VolumeHandle)

if err := p.checkDriverCapabilities(false); err != nil {
if err = p.checkDriverCapabilities(false); err != nil {
return err
}

Expand Down Expand Up @@ -681,7 +698,7 @@ func (p *csiProvisioner) Delete(volume *v1.PersistentVolume) error {
ctx, cancel := context.WithTimeout(context.Background(), p.timeout)
defer cancel()

_, err := p.csiClient.DeleteVolume(ctx, &req)
_, err = p.csiClient.DeleteVolume(ctx, &req)

return err
}
Expand Down