-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Improve validation for extra-config. #10886
Improve validation for extra-config. #10886
Conversation
Welcome @vishjain! |
Hi @vishjain. Thanks for your PR. I'm waiting for a kubernetes 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. |
Can one of the admins verify this patch? |
pkg/minikube/config/extra_options.go
Outdated
|
||
// Check doesn't start or end with an opening quotation. | ||
if strings.HasPrefix(value, "“") || strings.HasSuffix(value, "“") { | ||
return fmt.Errorf("invalid value: canot contain quotation: %q", value) |
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.
Can you verify if this is actually true ? Could it be it hangs only if the there is One Qutation without closing ?
Do u mind posting the output of minikube fore and after this PR?
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.
My mistake: There is only hanging currently if at the end there is a quotation mark:
minikube vishal$ ./out/minikube start --driver=docker --extra-config=etcd.client-cert-auth=false“
😄 minikube v1.18.1 on Darwin 10.14.6
✨ Using the docker driver based on existing profile
👍 Starting control plane node minikube in cluster minikube
🏃 Updating the running docker "minikube" container ...
🐳 Preparing Kubernetes v1.20.2 on Docker 20.10.3 ...
▪ etcd.client-cert-auth=false“
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.
There is already an error that shows up when there is a quote at the beginning too:
./out/minikube start --driver=docker --extra-config=“etcd.client-cert-auth=false”
😄 minikube v1.18.1 on Darwin 10.14.6
✨ Using the docker driver based on existing profile
❗ These --extra-config parameters are invalid: [“etcd]
❌ Exiting due to MK_USAGE: Valid components are: [apiserver controller-manager scheduler etcd kubeadm kubelet kube-proxy]
So we need to just check the end of the string for a quote.
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.
./out/minikube start --driver=docker --extra-config=“etcd.client-cert-auth=false
😄 minikube v1.18.1 on Darwin 10.14.6
✨ Using the docker driver based on existing profile
❗ These --extra-config parameters are invalid: [“etcd]
❌ Exiting due to MK_USAGE: Valid components are: [apiserver controller-manager scheduler etcd kubeadm kubelet kube-proxy]
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 have preserved the initial errors and also added the error when there's a suffix quote at the end:
./out/minikube start --driver=docker --extra-config=etcd.client-cert-auth=false”
Error: invalid argument "etcd.client-cert-auth=false”" for "--extra-config" flag: invalid value: cannot contain end quotation: "etcd.client-cert-auth=false”"
pkg/minikube/config/extra_options.go
Outdated
prefixExists := strings.HasPrefix(value, "”") || strings.HasPrefix(value, "“") | ||
suffixExists := strings.HasSuffix(value, "”") || strings.HasSuffix(value, "“") | ||
if !prefixExists && suffixExists { | ||
return fmt.Errorf("invalid value: cannot contain end quotation: %q", value) |
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.
what happens when error happens ? could u paste in the PR description
Before and After this PR ?
how about adding Unit test for Set
Function ? with example of things that should Error and example of things that should NOT error
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.
also improve the error wording, -extra-config
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've added a test and in the PR description above I've included what happens when we do the error checking. We are stopping he hanging occurring when a extra-config value ends with a open or close quote. It's important to note if the extra-config value has a prefix with an open or close quote then there's a separate error check in start.go file (cli) - I have left that alone.
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.
@vishjain please fix the lint, run "make test"
@medyagh I ran make test and make lint. Hope it's good now. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: medyagh, vishjain 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 |
fixes #8694
Here is the output with the PR changes:
vishals-MacBook-Pro:minikube vishal$ ./out/minikube start --driver=docker --extra-config=etcd.client-cert-auth=false”
Error: invalid argument "etcd.client-cert-auth=false”" for "--extra-config" flag: invalid value: cannot contain end quotation: "etcd.client-cert-auth=false”"
See 'minikube start --help' for usage.
Before, the ./out/minikube start command would just hang. This PR handles the case where end of --extra-config value has an open/close quotation because that's where the hanging behavior occurs.