Skip to content

Commit

Permalink
Ignore provisioning for in-tree volumes that have not been migrated
Browse files Browse the repository at this point in the history
  • Loading branch information
davidz627 committed Sep 12, 2019
1 parent dfae8d4 commit 768ed56
Show file tree
Hide file tree
Showing 2 changed files with 155 additions and 30 deletions.
13 changes: 12 additions & 1 deletion pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ const (
tokenPVCNameSpaceKey = "pvc.namespace"

deleteVolumeRetryCount = 5

annStorageProvisioner = "volume.beta.kubernetes.io/storage-provisioner"
)

var (
Expand Down Expand Up @@ -369,6 +371,14 @@ func (p *csiProvisioner) ProvisionExt(options controller.ProvisionOptions) (*v1.
return nil, controller.ProvisioningFinished, errors.New("storage class was nil")
}

if options.PVC.Annotations[annStorageProvisioner] != p.driverName {
return nil, controller.ProvisioningFinished, &controller.IgnoredError{
Reason: fmt.Sprintf("PVC annotated with external-provisioner name %s does not match provisioner driver name %s. This could mean the PVC is not migrated",
options.PVC.Annotations[annStorageProvisioner],
p.driverName),
}
}

migratedVolume := false
if p.supportsMigrationFromInTreePluginName != "" {
// NOTE: we cannot depend on PVC.Annotations[volume.beta.kubernetes.io/storage-provisioner] to get
Expand Down Expand Up @@ -617,6 +627,8 @@ func (p *csiProvisioner) ProvisionExt(options controller.ProvisionOptions) (*v1.
pv.Spec.PersistentVolumeSource.CSI.FSType = fsType
}

klog.V(2).Infof("successfully created PV %v for PVC %v and csi volume name %v", pv.Name, options.PVC.Name, pv.Spec.CSI.VolumeHandle)

if migratedVolume {
pv, err = csitranslationlib.TranslateCSIPVToInTree(pv)
if err != nil {
Expand All @@ -631,7 +643,6 @@ func (p *csiProvisioner) ProvisionExt(options controller.ProvisionOptions) (*v1.
}
}

klog.V(2).Infof("successfully created PV %v for PVC %v and csi volume name %v", pv.Name, options.PVC.Name, pv.Spec.CSI.VolumeHandle)
klog.V(5).Infof("successfully created PV %+v", pv.Spec.PersistentVolumeSource)
return pv, controller.ProvisioningFinished, nil
}
Expand Down
Loading

0 comments on commit 768ed56

Please sign in to comment.