-
Notifications
You must be signed in to change notification settings - Fork 867
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
Check file path before Initialize crd #2207
Conversation
d778ca1
to
962cd11
Compare
/cc @prodanlabs |
/assign @prodanlabs |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Sorry for letting this sit. |
Sure, thanks |
/assign @RainbowMango |
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'll try to get back on this by this week.
@chaosi-zju Would you like to take a look?
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.
Hello, thank you for your important commit! Review is ongoing, and my viewpoint just for reference only.
if os.IsNotExist(err) { | ||
return err | ||
} | ||
return nil |
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.
Hello, I wanna why if err != nil && !os.IsNotExist(err)
, we not return the err but return nil?
how about like this:
func PathExist(path string) error {
_, err := os.Stat(path)
if err != nil && !os.IsExist(err) {
return err
}
return nil
}
if err := utils.PathExists(dir + "/crds/bases"); err != nil { | ||
return err | ||
} | ||
basesCRDsFiles := utils.ListFiles(dir + "/crds/bases") |
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.
Hi, have you tested if this dir is just a empty dir, if there is any other unexpected failure?
} | ||
} | ||
|
||
if err := utils.PathExists(dir + "/crds/patches"); err != nil { |
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.
ditto
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.
Just looked into it.
The root cause seems that the filepath.Walk might arise an error(like no such file or directory
) when visiting the path(in this case it is the non-exist /crds/bases
), this error should be handled but accidentally be ignored at here:
karmada/pkg/karmadactl/cmdinit/utils/util.go
Line 133 in ef87bd2
if !info.IsDir() { |
Currently, we lack an efficient way to validate a specified crd.tar.gz
, this approach just focuses on checking if crds/base
and crds/patches
exist or not, it's a little bit restrictive. E.g. what if these paths exist but don't have the expected files? (I didn't test it, just a guess, it will make things worse, because it may mask the issue and allow the entire installation process to continue, giving the user a false impression of successful installation, which I mean it is worse.)
So, my opinion is either to establish a comprehensive validation mechanism for the crds.tar.gz
based on this issue or temporarily postpone this issue.
Signed-off-by: xin.li <xin.li@daocloud.io>
Yes, it seems that this PR has a lot of limitations |
/close Please reopen it if you think we still need it. |
@RainbowMango: Closed this PR. In response to this:
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. |
What type of PR is this?
/kind bug
What this PR does / why we need it:
1.When we run
karmadactl init --kube-image-registry=registry.cn-hangzhou.aliyuncs.com/google_containers --crds /root/crds.tar.gz
2.If the crds dir do not has patches or bases, like
Command output file does not exist, and exit
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
The test result:
Does this PR introduce a user-facing change?: