Skip to content

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

Merged
merged 5 commits into from
May 28, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pkg/gce-pd-csi-driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Copy link
Contributor

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)

Copy link
Contributor

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

}

if acquired := gceCS.volumeLocks.TryAcquire(volumeID); !acquired {
return nil, status.Errorf(codes.Aborted, common.VolumeOperationAlreadyExistsFmt, volumeID)
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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.")
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The 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)
Expand Down