Commit c26bd886 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

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.
parents 70c97b2c 8ebed577
...@@ -1329,7 +1329,9 @@ func (ctrl *PersistentVolumeController) provisionClaimOperation(claimObj interfa ...@@ -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
......
...@@ -42,8 +42,10 @@ type VolumeOptions struct { ...@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment