Skip to content

Commit

Permalink
Merge pull request #276 from ddebroy/release-1.1
Browse files Browse the repository at this point in the history
Cherry pick handling of deletion of CSI migrated volumes
  • Loading branch information
k8s-ci-robot authored May 8, 2019
2 parents cecb5a9 + 8b46cbb commit cfb8518
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG-1.1.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
23 changes: 20 additions & 3 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit cfb8518

Please sign in to comment.