-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Ensure 'not exist' errors wrap os.ErrNotExist #3982
Conversation
Hi @campoy. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
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.
The presubmit check is failing because the api module is missing a go.sum entry, you can see the error output here: https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_kustomize/3982/kustomize-presubmit-master/1403066536456884224
Besides that, the change looks okay to me, though could you clarify what benefit this provides?
@campoy: This PR has multiple commits, and the default merge method is: merge. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Of course, yes. I'm working on #3873 and I want to ensure that the behavior of the different implementations of Right now, some of the checks that I would do are failing because the error returned when opening a non existent file on FsOnDisk do wrap os.ErrNotExist, but not FsInMemory. I also just sent an updated go.sum. |
Regarding the multiple commits, I'm totally fine squashing them but I don't think I can request that myself. Should I squash it manually on my end? |
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.
Minor nits
api/filesys/fsnode.go
Outdated
@@ -236,7 +236,7 @@ func (n *fsNode) CleanedAbs(path string) (ConfirmedDir, string, error) { | |||
return "", "", errors.Wrap(err, "unable to clean") | |||
} | |||
if node == nil { | |||
return "", "", fmt.Errorf("'%s' doesn't exist", path) | |||
return "", "", fmt.Errorf("'%s' doesn't exist: %w", path, os.ErrNotExist) |
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.
This seems a bit redundant. Maybe just fmt.Errorf("'%s': %w", path, osErr.NotExist)
so that the output reads 'filename': file does not exist
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.
Fixed
api/filesys/fsnode.go
Outdated
@@ -351,6 +352,9 @@ func (n *fsNode) IsDir(path string) bool { | |||
|
|||
// ReadDir implements FileSystem. | |||
func (n *fsNode) ReadDir(path string) ([]string, error) { | |||
if !n.Exists(path) { | |||
return nil, fmt.Errorf("%s does not exist: %w", path, os.ErrNotExist) |
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.
same comment here as above, and let's put single quotes around '%s'
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.
Fixed
note: You can run |
After having to fix too many tests, I realized that there was a way to avoid having to change anything on the client's side by using a custom error type! |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: campoy, natasha41575 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Updates #3873
This PR ensures that all "not exist" types return an error for which errors.Is(err, os.ErrNotExist) is true.