-
Notifications
You must be signed in to change notification settings - Fork 159
Improve error messages for ControllerExpandVolume / CreateSnapshot of multi-zone PV. #1718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
3137bf0
015dede
a72836c
eb3e6eb
6a7146b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1158,6 +1158,11 @@ func (gceCS *GCEControllerServer) CreateSnapshot(ctx context.Context, req *csi.C | |
return nil, status.Errorf(codes.InvalidArgument, "CreateSnapshot Volume ID is invalid: %v", err.Error()) | ||
} | ||
|
||
volumeIsMultiZone := isMultiZoneVolKey(volKey) | ||
if gceCS.multiZoneVolumeHandleConfig.Enable && volumeIsMultiZone { | ||
return nil, fmt.Errorf("Snapshots are not supported with the `multi-zone` PV volumeHandle feature.") | ||
} | ||
|
||
if acquired := gceCS.volumeLocks.TryAcquire(volumeID); !acquired { | ||
return nil, status.Errorf(codes.Aborted, common.VolumeOperationAlreadyExistsFmt, volumeID) | ||
} | ||
|
@@ -1203,6 +1208,7 @@ func (gceCS *GCEControllerServer) createPDSnapshot(ctx context.Context, project | |
if err != nil { | ||
return nil, status.Errorf(codes.InvalidArgument, "Invalid volume key: %v", volKey) | ||
} | ||
|
||
// Check if PD snapshot already exists | ||
var snapshot *compute.Snapshot | ||
snapshot, err = gceCS.CloudProvider.GetSnapshot(ctx, project, snapshotName) | ||
|
@@ -1482,6 +1488,7 @@ func (gceCS *GCEControllerServer) ListSnapshots(ctx context.Context, req *csi.Li | |
} | ||
|
||
func (gceCS *GCEControllerServer) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) { | ||
|
||
var err error | ||
diskTypeForMetric := metrics.DefaultDiskTypeForMetric | ||
enableConfidentialCompute := metrics.DefaultEnableConfidentialCompute | ||
|
@@ -1504,12 +1511,19 @@ func (gceCS *GCEControllerServer) ControllerExpandVolume(ctx context.Context, re | |
return nil, status.Errorf(codes.InvalidArgument, "ControllerExpandVolume Volume ID is invalid: %v", err.Error()) | ||
} | ||
project, volKey, err = gceCS.CloudProvider.RepairUnderspecifiedVolumeKey(ctx, project, volKey) | ||
|
||
if err != nil { | ||
if gce.IsGCENotFoundError(err) { | ||
return nil, status.Errorf(codes.NotFound, "ControllerExpandVolume could not find volume with ID %v: %v", volumeID, err.Error()) | ||
} | ||
return nil, common.LoggedError("ControllerExpandVolume error repairing underspecified volume key: ", err) | ||
} | ||
|
||
volumeIsMultiZone := isMultiZoneVolKey(volKey) | ||
if gceCS.multiZoneVolumeHandleConfig.Enable && volumeIsMultiZone { | ||
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.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think naming this "ControllerExpandVolume" instead of "Resize operation" is actually better. It describes the RPC, as "Resize" is more of a Container Orchestrator term. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use "volume" instead of "disk". Also, print out the volumeID in the error message |
||
} | ||
|
||
sourceDisk, err := gceCS.CloudProvider.GetDisk(ctx, project, volKey, gce.GCEAPIVersionV1) | ||
diskTypeForMetric, enableConfidentialCompute, enableStoragePools = metrics.GetMetricParameters(sourceDisk) | ||
resizedGb, err := gceCS.CloudProvider.ResizeDisk(ctx, project, volKey, reqBytes) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should return a proper status.Error (eg: InvalidArgument)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also omit the backticks. This will be printed to the terminal, so it won't be markdown formatted