Skip to content

Commit 3137bf0

Browse files
committed
improve error messages for multi-PV ControllerExpandVolume/CreateSnapshot
1 parent 586f6c8 commit 3137bf0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,12 @@ func (gceCS *GCEControllerServer) createPDSnapshot(ctx context.Context, project
12031203
if err != nil {
12041204
return nil, status.Errorf(codes.InvalidArgument, "Invalid volume key: %v", volKey)
12051205
}
1206+
1207+
volumeIsMultiZone := isMultiZoneVolKey(volKey)
1208+
if gceCS.multiZoneVolumeHandleConfig.Enable && volumeIsMultiZone {
1209+
return nil, fmt.Errorf("Snapshots are not supported with the `multi-zone` PV volumeHandle feature.")
1210+
}
1211+
12061212
// Check if PD snapshot already exists
12071213
var snapshot *compute.Snapshot
12081214
snapshot, err = gceCS.CloudProvider.GetSnapshot(ctx, project, snapshotName)
@@ -1482,6 +1488,7 @@ func (gceCS *GCEControllerServer) ListSnapshots(ctx context.Context, req *csi.Li
14821488
}
14831489

14841490
func (gceCS *GCEControllerServer) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) {
1491+
14851492
var err error
14861493
diskTypeForMetric := metrics.DefaultDiskTypeForMetric
14871494
enableConfidentialCompute := metrics.DefaultEnableConfidentialCompute
@@ -1504,12 +1511,19 @@ func (gceCS *GCEControllerServer) ControllerExpandVolume(ctx context.Context, re
15041511
return nil, status.Errorf(codes.InvalidArgument, "ControllerExpandVolume Volume ID is invalid: %v", err.Error())
15051512
}
15061513
project, volKey, err = gceCS.CloudProvider.RepairUnderspecifiedVolumeKey(ctx, project, volKey)
1514+
15071515
if err != nil {
15081516
if gce.IsGCENotFoundError(err) {
15091517
return nil, status.Errorf(codes.NotFound, "ControllerExpandVolume could not find volume with ID %v: %v", volumeID, err.Error())
15101518
}
15111519
return nil, common.LoggedError("ControllerExpandVolume error repairing underspecified volume key: ", err)
15121520
}
1521+
1522+
volumeIsMultiZone := isMultiZoneVolKey(volKey)
1523+
if gceCS.multiZoneVolumeHandleConfig.Enable && volumeIsMultiZone {
1524+
return nil, fmt.Errorf("Resize operation is not supported with the `multi-zone` PVC volumeHandle feature. Please re-create the disk from source if you want a larger size.")
1525+
}
1526+
15131527
sourceDisk, err := gceCS.CloudProvider.GetDisk(ctx, project, volKey, gce.GCEAPIVersionV1)
15141528
diskTypeForMetric, enableConfidentialCompute, enableStoragePools = metrics.GetMetricParameters(sourceDisk)
15151529
resizedGb, err := gceCS.CloudProvider.ResizeDisk(ctx, project, volKey, reqBytes)

0 commit comments

Comments
 (0)