Commit 01b20d8e authored by Jan Safranek's avatar Jan Safranek

Generate shorter provisioned PV names.

GCE PD names are generated out of provisioned PV.Name, therefore it should be as short as possible and still unique.
parent 79b91b9e
...@@ -1169,7 +1169,7 @@ func (ctrl *PersistentVolumeController) provisionClaimOperation(claimObj interfa ...@@ -1169,7 +1169,7 @@ func (ctrl *PersistentVolumeController) provisionClaimOperation(claimObj interfa
// getProvisionedVolumeNameForClaim returns PV.Name for the provisioned volume. // getProvisionedVolumeNameForClaim returns PV.Name for the provisioned volume.
// The name must be unique // The name must be unique
func (ctrl *PersistentVolumeController) getProvisionedVolumeNameForClaim(claim *api.PersistentVolumeClaim) string { func (ctrl *PersistentVolumeController) getProvisionedVolumeNameForClaim(claim *api.PersistentVolumeClaim) string {
return "pv-provisioned-for-" + string(claim.UID) return "pvc-" + string(claim.UID)
} }
// scheduleOperation starts given asynchronous operation on given volume. It // scheduleOperation starts given asynchronous operation on given volume. It
......
...@@ -33,7 +33,7 @@ func TestProvisionSync(t *testing.T) { ...@@ -33,7 +33,7 @@ func TestProvisionSync(t *testing.T) {
// Provision a volume // Provision a volume
"11-1 - successful provision", "11-1 - successful provision",
novolumes, novolumes,
newVolumeArray("pv-provisioned-for-uid11-1", "1Gi", "uid11-1", "claim11-1", api.VolumeBound, api.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned), newVolumeArray("pvc-uid11-1", "1Gi", "uid11-1", "claim11-1", api.VolumeBound, api.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned),
newClaimArray("claim11-1", "uid11-1", "1Gi", "", api.ClaimPending, annClass), newClaimArray("claim11-1", "uid11-1", "1Gi", "", api.ClaimPending, annClass),
// Binding will be completed in the next syncClaim // Binding will be completed in the next syncClaim
newClaimArray("claim11-1", "uid11-1", "1Gi", "", api.ClaimPending, annClass), newClaimArray("claim11-1", "uid11-1", "1Gi", "", api.ClaimPending, annClass),
...@@ -76,7 +76,7 @@ func TestProvisionSync(t *testing.T) { ...@@ -76,7 +76,7 @@ func TestProvisionSync(t *testing.T) {
newVolumeArray("volume11-6", "1Gi", "", "", api.VolumePending, api.PersistentVolumeReclaimRetain), newVolumeArray("volume11-6", "1Gi", "", "", api.VolumePending, api.PersistentVolumeReclaimRetain),
[]*api.PersistentVolume{ []*api.PersistentVolume{
newVolume("volume11-6", "1Gi", "", "", api.VolumePending, api.PersistentVolumeReclaimRetain), newVolume("volume11-6", "1Gi", "", "", api.VolumePending, api.PersistentVolumeReclaimRetain),
newVolume("pv-provisioned-for-uid11-6", "1Gi", "uid11-6", "claim11-6", api.VolumeBound, api.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned), newVolume("pvc-uid11-6", "1Gi", "uid11-6", "claim11-6", api.VolumeBound, api.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned),
}, },
newClaimArray("claim11-6", "uid11-6", "1Gi", "", api.ClaimPending, annClass), newClaimArray("claim11-6", "uid11-6", "1Gi", "", api.ClaimPending, annClass),
// Binding will be completed in the next syncClaim // Binding will be completed in the next syncClaim
...@@ -91,7 +91,7 @@ func TestProvisionSync(t *testing.T) { ...@@ -91,7 +91,7 @@ func TestProvisionSync(t *testing.T) {
// a volume. // a volume.
"11-7 - claim is bound before provisioning", "11-7 - claim is bound before provisioning",
novolumes, novolumes,
newVolumeArray("pv-provisioned-for-uid11-7", "1Gi", "uid11-7", "claim11-7", api.VolumeBound, api.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned), newVolumeArray("pvc-uid11-7", "1Gi", "uid11-7", "claim11-7", api.VolumeBound, api.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned),
newClaimArray("claim11-7", "uid11-7", "1Gi", "", api.ClaimPending, annClass), newClaimArray("claim11-7", "uid11-7", "1Gi", "", api.ClaimPending, annClass),
// The claim would be bound in next syncClaim // The claim would be bound in next syncClaim
newClaimArray("claim11-7", "uid11-7", "1Gi", "", api.ClaimPending, annClass), newClaimArray("claim11-7", "uid11-7", "1Gi", "", api.ClaimPending, annClass),
...@@ -100,7 +100,7 @@ func TestProvisionSync(t *testing.T) { ...@@ -100,7 +100,7 @@ func TestProvisionSync(t *testing.T) {
// Create a volume before provisionClaimOperation starts. // Create a volume before provisionClaimOperation starts.
// This similates a parallel controller provisioning the volume. // This similates a parallel controller provisioning the volume.
reactor.lock.Lock() reactor.lock.Lock()
volume := newVolume("pv-provisioned-for-uid11-7", "1Gi", "uid11-7", "claim11-7", api.VolumeBound, api.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned) volume := newVolume("pvc-uid11-7", "1Gi", "uid11-7", "claim11-7", api.VolumeBound, api.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned)
reactor.volumes[volume.Name] = volume reactor.volumes[volume.Name] = volume
reactor.lock.Unlock() reactor.lock.Unlock()
}), }),
...@@ -110,7 +110,7 @@ func TestProvisionSync(t *testing.T) { ...@@ -110,7 +110,7 @@ func TestProvisionSync(t *testing.T) {
// second retry succeeds // second retry succeeds
"11-8 - cannot save provisioned volume", "11-8 - cannot save provisioned volume",
novolumes, novolumes,
newVolumeArray("pv-provisioned-for-uid11-8", "1Gi", "uid11-8", "claim11-8", api.VolumeBound, api.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned), newVolumeArray("pvc-uid11-8", "1Gi", "uid11-8", "claim11-8", api.VolumeBound, api.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned),
newClaimArray("claim11-8", "uid11-8", "1Gi", "", api.ClaimPending, annClass), newClaimArray("claim11-8", "uid11-8", "1Gi", "", api.ClaimPending, annClass),
// Binding will be completed in the next syncClaim // Binding will be completed in the next syncClaim
newClaimArray("claim11-8", "uid11-8", "1Gi", "", api.ClaimPending, annClass), newClaimArray("claim11-8", "uid11-8", "1Gi", "", api.ClaimPending, annClass),
...@@ -244,10 +244,10 @@ func TestProvisionMultiSync(t *testing.T) { ...@@ -244,10 +244,10 @@ func TestProvisionMultiSync(t *testing.T) {
// Provision a volume with binding // Provision a volume with binding
"12-1 - successful provision", "12-1 - successful provision",
novolumes, novolumes,
newVolumeArray("pv-provisioned-for-uid12-1", "1Gi", "uid12-1", "claim12-1", api.VolumeBound, api.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned), newVolumeArray("pvc-uid12-1", "1Gi", "uid12-1", "claim12-1", api.VolumeBound, api.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned),
newClaimArray("claim12-1", "uid12-1", "1Gi", "", api.ClaimPending, annClass), newClaimArray("claim12-1", "uid12-1", "1Gi", "", api.ClaimPending, annClass),
// Binding will be completed in the next syncClaim // Binding will be completed in the next syncClaim
newClaimArray("claim12-1", "uid12-1", "1Gi", "pv-provisioned-for-uid12-1", api.ClaimBound, annClass, annBoundByController, annBindCompleted), newClaimArray("claim12-1", "uid12-1", "1Gi", "pvc-uid12-1", api.ClaimBound, annClass, annBoundByController, annBindCompleted),
noevents, noerrors, wrapTestWithControllerConfig(operationProvision, []error{nil}, testSyncClaim), noevents, noerrors, wrapTestWithControllerConfig(operationProvision, []error{nil}, testSyncClaim),
}, },
} }
......
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