mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
rbd: use internal as default error code in getGRPCError()
This commit replaces codes.Unknown with codes.Internal as the default error code in getGRPCError(). Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
@ -776,14 +776,10 @@ func getGRPCError(err error) error {
|
||||
}
|
||||
|
||||
errorStatusMap := map[error]codes.Code{
|
||||
corerbd.ErrFetchingLocalState: codes.Internal,
|
||||
corerbd.ErrResyncImageFailed: codes.Internal,
|
||||
corerbd.ErrDisableImageMirroringFailed: codes.Internal,
|
||||
corerbd.ErrFetchingMirroringInfo: codes.Internal,
|
||||
corerbd.ErrInvalidArgument: codes.InvalidArgument,
|
||||
corerbd.ErrAborted: codes.Aborted,
|
||||
corerbd.ErrFailedPrecondition: codes.FailedPrecondition,
|
||||
corerbd.ErrUnavailable: codes.Unavailable,
|
||||
corerbd.ErrInvalidArgument: codes.InvalidArgument,
|
||||
corerbd.ErrAborted: codes.Aborted,
|
||||
corerbd.ErrFailedPrecondition: codes.FailedPrecondition,
|
||||
corerbd.ErrUnavailable: codes.Unavailable,
|
||||
}
|
||||
|
||||
for e, code := range errorStatusMap {
|
||||
@ -792,8 +788,8 @@ func getGRPCError(err error) error {
|
||||
}
|
||||
}
|
||||
|
||||
// Handle any other non nil error not listed in the map
|
||||
return status.Error(codes.Unknown, err.Error())
|
||||
// Handle any other non nil error not listed in the map as internal error
|
||||
return status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
// GetVolumeReplicationInfo extracts the RBD volume information from the volumeID, If the
|
||||
|
@ -541,26 +541,6 @@ func TestGetGRPCError(t *testing.T) {
|
||||
err error
|
||||
expectedErr error
|
||||
}{
|
||||
{
|
||||
name: "FetchingLocalStateFailed",
|
||||
err: corerbd.ErrFetchingLocalState,
|
||||
expectedErr: status.Error(codes.Internal, corerbd.ErrFetchingLocalState.Error()),
|
||||
},
|
||||
{
|
||||
name: "ResyncImageFailed",
|
||||
err: corerbd.ErrResyncImageFailed,
|
||||
expectedErr: status.Error(codes.Internal, corerbd.ErrResyncImageFailed.Error()),
|
||||
},
|
||||
{
|
||||
name: "DisableImageMirroringFailed",
|
||||
err: corerbd.ErrDisableImageMirroringFailed,
|
||||
expectedErr: status.Error(codes.Internal, corerbd.ErrDisableImageMirroringFailed.Error()),
|
||||
},
|
||||
{
|
||||
name: "FetchingMirroringInfoFailed",
|
||||
err: corerbd.ErrFetchingMirroringInfo,
|
||||
expectedErr: status.Error(codes.Internal, corerbd.ErrFetchingMirroringInfo.Error()),
|
||||
},
|
||||
{
|
||||
name: "InvalidArgument",
|
||||
err: corerbd.ErrInvalidArgument,
|
||||
@ -584,7 +564,7 @@ func TestGetGRPCError(t *testing.T) {
|
||||
{
|
||||
name: "InvalidError",
|
||||
err: errors.New("some error"),
|
||||
expectedErr: status.Error(codes.Unknown, "some error"),
|
||||
expectedErr: status.Error(codes.Internal, "some error"),
|
||||
},
|
||||
{
|
||||
name: "NilError",
|
||||
|
Reference in New Issue
Block a user