Merge pull request #40695 from vladimirvivien/vvivien-fix-volname-overwrite

Automatic merge from submit-queue (batch tested with PRs 40810, 40695)

Prevent pv controller from forcefully overwrite provisioned volume name

**What this PR does / why we need it**:
This PR adds a fix to prevents the PV controller from forcefully overwriting the provisioned volume's name with the generated PV name.  Instead, it overwrites the volume's name only when it is missing.  This allows dynamic provisioner implementers to set the name of the volume to a value that they choose.

**Which issue this PR fixes** 
This PR does not have an issue affiliated, but it will allow PR #38924 to properly implement dynamically provisioned volume in namespaces other than default.
This commit is contained in:
Kubernetes Submit Queue 2017-02-02 08:07:48 -08:00 committed by GitHub
commit c26bd88620
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))
// Create Kubernetes PV object for the volume.
volume.Name = pvName
if volume.Name == "" {
volume.Name = pvName
}
// Bind it to the claim
volume.Spec.ClaimRef = claimRef
volume.Status.Phase = v1.VolumeBound

View File

@ -42,8 +42,10 @@ type VolumeOptions struct {
// Reclamation policy for a persistent volume
PersistentVolumeReclaimPolicy v1.PersistentVolumeReclaimPolicy
// PV.Name of the appropriate PersistentVolume. Used to generate cloud
// volume name.
// Suggested PV.Name of the PersistentVolume to provision.
// 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
// 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,