-
Notifications
You must be signed in to change notification settings - Fork 257
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
Introduce common cephError type to compare errors between packages #1032
Conversation
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.
Generally looks good to me.
Shouldn't we consider updating the API docs about those older implementations getting removed?
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.
We could also either:
- rename and move internal/errors_test.go to internal/errutil/error_test.go
OR - rename internal/errutil/error.go to internal/errutil/errors.go and move internal/errutil/errors_test.go to internal/errutil/errors_test.go
@anoopcs9 the file naming an location is actually intentional, because of two reasons:
If you insist on renaming/moving, I'll do that. Please state your preference in that case. Thanks! |
The implementation is an internal-only change. I do not expect any visible changes on the outside, all should be backwards compatible. |
In that case how about we rewrite errors_test.go in the direction of strerror_test.go and put in under internal/errutil?
I agree but those APIs would still remain listed in docs/api-status.json. |
oh, right, I see |
Hey @anoopcs9,
Just to confirm, also tests may not do the 2-way imports:
The main thing it tests is comparing errors between the Do you have an other idea where to place
The references to internal error types have been removed now. |
May be we choose option 1 to rename and move internal/errors_test.go to internal/errutil/error_test.go as follows:
Are you sure you pushed those changes? I don't see any update here. |
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.
Great, looks good to me 👍
Thanks for the changes!
@Mergifyio rebase |
✅ Branch has been successfully rebased |
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.
lgtm, thanks.
Oh..I totally forgot this afterwards. Do you want to take this final step? |
Pull request has been modified.
@Mergifyio rebase |
Signed-off-by: Niels de Vos <[email protected]>
Signed-off-by: Niels de Vos <[email protected]>
Signed-off-by: Niels de Vos <[email protected]>
Signed-off-by: Niels de Vos <[email protected]>
Signed-off-by: Niels de Vos <[email protected]> Signed-off-by: Anoop C S <[email protected]>
Following APIs have been replaced with more generic cephError type to jointly indicate the source and error. cephFSError.Error cephFSError.ErrorCode radosError.Error radosError.ErrorCode rbdError.Error rbdError.ErrorCode Therefore remove corresponding entries from API docs. Signed-off-by: Anoop C S <[email protected]>
✅ Branch has been successfully rebased |
A new
internal/errutil.cephError
can be used as a common type to replace all error types that are specific to the different packages (cephfsError
,radosError
,rbdError
). By using the newcephError
type everywhere, it becomes possible to matchrados.ErrNotFound
andrbd.ErrNotFound
with the standarderrors.Is()
function.Some go-ceph functions from the cephfs and rbd packages can return errors generated by the lower-level rados package. In such a case, a caller may need to check for e.g.
rados.ErrNotFound
as well asrbd.ErrNotFound
, depending on the function that was called. This is prone to errors, as users of go-ceph may not inspect what the go-ceph function does and which error type it could return.Closes: #1031
Checklist
//go:build ceph_preview
make api-update
to record new APIsNew or infrequent contributors may want to review the go-ceph Developer's Guide including the section on how we track API Status and the API Stability Plan.
The go-ceph project uses mergify. View the mergify command guide for information on how to interact with mergify. Add a comment with
@Mergifyio
rebase
to rebase your PR when github indicates that the PR is out of date with the base branch.