Skip to content

Commit 597c90a

Browse files
committed
parent 19d670f
author Alexis MacAskill <[email protected]> 1634669949 +0000 committer Alexis MacAskill <[email protected]> 1636674064 +0000 added volume cloning
1 parent 19d670f commit 597c90a

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

deploy/kubernetes/images/prow-gke-release-staging-rc-master/image.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@ metadata:
5353
imageTag:
5454
name: k8s.gcr.io/cloud-provider-gcp/gcp-compute-persistent-disk-csi-driver
5555
newName: gcr.io/k8s-staging-cloud-provider-gcp/gcp-compute-persistent-disk-csi-driver
56-
newTag: "v1.3.2-rc1"
56+
newTag: "v1.3.4-rc1"
5757
---

pkg/gce-cloud-provider/compute/cloud-disk.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func (d *CloudDisk) GetSnapshotId() string {
177177
}
178178
}
179179

180-
func (d *CloudDisk) GetDiskId() string {
180+
func (d *CloudDisk) GetSourceDiskId() string {
181181
switch {
182182
case d.disk != nil:
183183
return d.disk.SourceDiskId

pkg/gce-pd-csi-driver/controller.go

+10-11
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,8 @@ func (gceCS *GCEControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
179179
if err != nil {
180180
return nil, status.Error(codes.Internal, fmt.Sprintf("CreateVolume disk %v had error checking ready status: %v", volKey, err))
181181
}
182-
183182
if !ready {
184-
return nil, status.Error(codes.Internal, fmt.Sprintf("CreateVolume disk %v is not ready", volKey))
183+
return nil, status.Error(codes.Internal, fmt.Sprintf("CreateVolume existing disk %v is not ready. Existing disk state= name: %v, ID: %v, status: %v, zone: %v, location-type: %v", volKey, existingDisk.GetName(), existingDisk.GetSourceDiskId(), existingDisk.GetStatus(), existingDisk.GetZone(), existingDisk.LocationType()))
185184
}
186185

187186
// If there is no validation error, immediately return success
@@ -207,12 +206,17 @@ func (gceCS *GCEControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
207206

208207
if content.GetVolume() != nil {
209208
volumeContentSourceVolumeID = content.GetVolume().GetVolumeId()
210-
211209
// Verify that the source VolumeID is in the correct format.
212-
project, volKey, err := common.VolumeIDToKey(volumeContentSourceVolumeID)
210+
_, _, err := common.VolumeIDToKey(volumeContentSourceVolumeID)
213211
if err != nil {
214212
return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("CreateVolume source volume ID is invalid: %v", err))
215213
}
214+
// Verify the volume in VolumeContentSource exists.
215+
if acquired := gceCS.volumeLocks.TryAcquire(volumeContentSourceVolumeID); acquired {
216+
return nil, status.Errorf(codes.NotFound, "CreateVolume source volume %s does not exist", volumeContentSourceVolumeID)
217+
}
218+
defer gceCS.volumeLocks.Release(volumeContentSourceVolumeID)
219+
216220
// Verify that the volume in VolumeContentSource exists.
217221
diskFromSourceVolume, err := gceCS.CloudProvider.GetDisk(ctx, project, volKey, gceAPIVersion)
218222
if err != nil {
@@ -222,12 +226,10 @@ func (gceCS *GCEControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
222226
return nil, status.Error(codes.Internal, fmt.Sprintf("CreateVolume unknown get disk error when validating: %v", err))
223227
}
224228
}
225-
226-
// Verify the zone, region, and disk type of the clone must be the same as that of the source disk.
229+
// Verify the zone, region, and disk type of the clone must be the same as that of the source disk.
227230
if err := gce.ValidateDiskParameters(diskFromSourceVolume, params); err != nil {
228231
return nil, status.Errorf(codes.InvalidArgument, `CreateVolume source volume parameters do not match CreateVolumeRequest Parameters: %v`, err)
229232
}
230-
231233
// Verify the source disk is ready.
232234
if err == nil {
233235
ready, err := isDiskReady(diskFromSourceVolume)
@@ -238,8 +240,6 @@ func (gceCS *GCEControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
238240
return nil, status.Error(codes.Internal, fmt.Sprintf("CreateVolume disk from source volume %v is not ready", volKey))
239241
}
240242
}
241-
//TODO does this go inside of err == nil?
242-
243243
}
244244
}
245245
// Create the disk
@@ -1089,7 +1089,7 @@ func generateCreateVolumeResponse(disk *gce.CloudDisk, zones []string) *csi.Crea
10891089
},
10901090
}
10911091
snapshotID := disk.GetSnapshotId()
1092-
diskID := disk.GetDiskId()
1092+
diskID := disk.GetSourceDiskId()
10931093
if diskID != "" || snapshotID != "" {
10941094
contentSource := &csi.VolumeContentSource{}
10951095
if snapshotID != "" {
@@ -1101,7 +1101,6 @@ func generateCreateVolumeResponse(disk *gce.CloudDisk, zones []string) *csi.Crea
11011101
},
11021102
}
11031103
}
1104-
diskID := disk.GetDiskId()
11051104
if diskID != "" {
11061105
contentSource = &csi.VolumeContentSource{
11071106
Type: &csi.VolumeContentSource_Volume{

test/k8s-integration/driver-config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ func generateDriverConfigFile(testParams *testParameters, storageClassFile strin
7676
}
7777

7878
/* Unsupported Capabilities:
79-
pvcDataSource
8079
RWX
8180
volumeLimits # PD Supports volume limits but test is very slow
8281
singleNodeVolume
@@ -117,6 +116,7 @@ func generateDriverConfigFile(testParams *testParameters, storageClassFile strin
117116
absSnapshotClassFilePath = filepath.Join(testParams.pkgDir, testConfigDir, testParams.snapshotClassFile)
118117
}
119118

119+
caps = append(caps, "pvcDataSource")
120120
minimumVolumeSize := "5Gi"
121121
numAllowedTopologies := 1
122122
if storageClassFile == regionalPDStorageClass {

0 commit comments

Comments
 (0)