Prevent pv controller from forcefully overwrite provisioned volume name

This fix prevents the PV controller from forcefully overwriting the provisioned volume's name with the generated PV name.  Instead, it allows dynamic provisioner implementers to set the name of the volume to a value that they choose.
This commit is contained in:
Vladimir Vivien 2017-01-30 12:15:44 -05:00
parent cb758738f9
commit 8ebed57767
2 changed files with 7 additions and 3 deletions

View File

@ -1329,7 +1329,9 @@ func (ctrl *PersistentVolumeController) provisionClaimOperation(claimObj interfa
glog.V(3).Infof("volume %q for claim %q created", volume.Name, claimToClaimKey(claim)) glog.V(3).Infof("volume %q for claim %q created", volume.Name, claimToClaimKey(claim))
// Create Kubernetes PV object for the volume. // Create Kubernetes PV object for the volume.
volume.Name = pvName if volume.Name == "" {
volume.Name = pvName
}
// Bind it to the claim // Bind it to the claim
volume.Spec.ClaimRef = claimRef volume.Spec.ClaimRef = claimRef
volume.Status.Phase = v1.VolumeBound volume.Status.Phase = v1.VolumeBound

View File

@ -42,8 +42,10 @@ type VolumeOptions struct {
// Reclamation policy for a persistent volume // Reclamation policy for a persistent volume
PersistentVolumeReclaimPolicy v1.PersistentVolumeReclaimPolicy PersistentVolumeReclaimPolicy v1.PersistentVolumeReclaimPolicy
// PV.Name of the appropriate PersistentVolume. Used to generate cloud // Suggested PV.Name of the PersistentVolume to provision.
// volume name. // This is a generated name guaranteed to be unique in Kubernetes cluster.
// If you choose not to use it as volume name, ensure uniqueness by either
// combining it with your value or create unique values of your own.
PVName string PVName string
// PVC is reference to the claim that lead to provisioning of a new PV. // PVC is reference to the claim that lead to provisioning of a new PV.
// Provisioners *must* create a PV that would be matched by this PVC, // Provisioners *must* create a PV that would be matched by this PVC,