Skip to content

Commit cfb8518

Browse files
authored
Merge pull request #276 from ddebroy/release-1.1
Cherry pick handling of deletion of CSI migrated volumes
2 parents cecb5a9 + 8b46cbb commit cfb8518

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

CHANGELOG-1.1.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Changelog since v1.1.0
2+
3+
## Notable Changes
4+
* Handle deletion of volumes associated with in-tree plugins that are migrated to CSI ([#276](https://github.com/kubernetes-csi/external-provisioner/pull/276))
5+
16
# Changelog since v1.0.1
27

38
## Breaking Changes

pkg/controller/controller.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -647,12 +647,29 @@ func (p *csiProvisioner) getVolumeContentSource(options controller.VolumeOptions
647647
}
648648

649649
func (p *csiProvisioner) Delete(volume *v1.PersistentVolume) error {
650-
if volume == nil || volume.Spec.CSI == nil {
650+
if volume == nil {
651651
return fmt.Errorf("invalid CSI PV")
652652
}
653+
654+
var err error
655+
if csitranslationlib.IsPVMigratable(volume) {
656+
// we end up here only if CSI migration is enabled in-tree (both overall
657+
// and for the specific plugin that is migratable) causing in-tree PV
658+
// controller to yield deletion of PVs with in-tree source to external provisioner
659+
// based on AnnDynamicallyProvisioned annotation.
660+
volume, err = csitranslationlib.TranslateInTreePVToCSI(volume)
661+
if err != nil {
662+
return err
663+
}
664+
}
665+
666+
if volume.Spec.CSI == nil {
667+
return fmt.Errorf("invalid CSI PV")
668+
}
669+
653670
volumeId := p.volumeHandleToId(volume.Spec.CSI.VolumeHandle)
654671

655-
if err := p.checkDriverCapabilities(false); err != nil {
672+
if err = p.checkDriverCapabilities(false); err != nil {
656673
return err
657674
}
658675

@@ -680,7 +697,7 @@ func (p *csiProvisioner) Delete(volume *v1.PersistentVolume) error {
680697
ctx, cancel := context.WithTimeout(context.Background(), p.timeout)
681698
defer cancel()
682699

683-
_, err := p.csiClient.DeleteVolume(ctx, &req)
700+
_, err = p.csiClient.DeleteVolume(ctx, &req)
684701

685702
return err
686703
}

0 commit comments

Comments
 (0)