Skip to content

Commit 1b8745e

Browse files
committed
-add back in check source disk is ready
1 parent 2826bde commit 1b8745e

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

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

+12-12
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func (gceCS *GCEControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
180180
return nil, status.Error(codes.Internal, fmt.Sprintf("CreateVolume disk %v had error checking ready status: %v", volKey, err))
181181
}
182182
if !ready {
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.GetDiskId(), existingDisk.GetStatus(), existingDisk.GetZone(), existingDisk.LocationType()))
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()))
184184
}
185185

186186
// If there is no validation error, immediately return success
@@ -225,16 +225,16 @@ func (gceCS *GCEControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
225225
if err := gce.ValidateDiskParameters(diskFromSourceVolume, params); err != nil {
226226
return nil, status.Errorf(codes.InvalidArgument, `CreateVolume source volume parameters do not match CreateVolumeRequest Parameters: %v`, err)
227227
}
228-
// // Verify the source disk is ready.
229-
// if err == nil {
230-
// ready, err := isDiskReady(diskFromSourceVolume)
231-
// if err != nil {
232-
// return nil, status.Error(codes.Internal, fmt.Sprintf("CreateVolume disk from source volume %v had error checking ready status: %v", volKey, err))
233-
// }
234-
// if !ready {
235-
// return nil, status.Error(codes.Internal, fmt.Sprintf("CreateVolume disk from source volume %v is not ready", volKey))
236-
// }
237-
// }
228+
// Verify the source disk is ready.
229+
if err == nil {
230+
ready, err := isDiskReady(diskFromSourceVolume)
231+
if err != nil {
232+
return nil, status.Error(codes.Internal, fmt.Sprintf("CreateVolume disk from source volume %v had error checking ready status: %v", volKey, err))
233+
}
234+
if !ready {
235+
return nil, status.Error(codes.Internal, fmt.Sprintf("CreateVolume disk from source volume %v is not ready", volKey))
236+
}
237+
}
238238
}
239239
}
240240
// Create the disk
@@ -1083,7 +1083,7 @@ func generateCreateVolumeResponse(disk *gce.CloudDisk, zones []string) *csi.Crea
10831083
},
10841084
}
10851085
snapshotID := disk.GetSnapshotId()
1086-
diskID := disk.GetDiskId()
1086+
diskID := disk.GetSourceDiskId()
10871087
if diskID != "" || snapshotID != "" {
10881088
contentSource := &csi.VolumeContentSource{}
10891089
if snapshotID != "" {

0 commit comments

Comments
 (0)