From b57cbc446886f24ab1f3a827b29b9000f3af0ffa Mon Sep 17 00:00:00 2001 From: Deep Debroy Date: Tue, 7 May 2019 11:58:10 -0700 Subject: [PATCH 1/2] Handle deletion of CSI migrated volumes Signed-off-by: Deep Debroy --- pkg/controller/controller.go | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index f11732319c..b97159dcaf 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -647,12 +647,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 } @@ -680,7 +697,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 } From 8b46cbb75811437c7a3f6d34297e8d121a607bf5 Mon Sep 17 00:00:00 2001 From: Deep Debroy Date: Wed, 8 May 2019 11:34:47 -0700 Subject: [PATCH 2/2] Changelog entry to handle deletion of CSI migrated volumes Signed-off-by: Deep Debroy --- CHANGELOG-1.1.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG-1.1.md b/CHANGELOG-1.1.md index 1856aa1112..6763647f17 100644 --- a/CHANGELOG-1.1.md +++ b/CHANGELOG-1.1.md @@ -1,3 +1,8 @@ +# Changelog since v1.1.0 + +## Notable Changes +* Handle deletion of volumes associated with in-tree plugins that are migrated to CSI ([#276](https://github.com/kubernetes-csi/external-provisioner/pull/276)) + # Changelog since v1.0.1 ## Breaking Changes