-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Use YAMLToJSONStrict instead of YAMLToJSON when loading patches #4000
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
base: main
Are you sure you want to change the base?
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: tom1299 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 |
|
Hi @tom1299. 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-sigs/prow repository. |
|
Some may expect the more lenient handling at this point. Not sure how big of an impact this would be. |
|
@stmcginnis I was thinking that as well. |
|
@stmcginnis I changed the implementation to a more permissive approach which just writes a warning to stderr: $ kind create cluster --config ./kind-config.yaml
Creating cluster "kind" ...
✓ Ensuring node image (kindest/node:v1.34.0) 🖼
✓ Preparing nodes 📦
⠈⠑ Writing configuration 📜
WARN: Error converting patch of kind InitConfiguration to json: "yaml: unmarshal errors:
line 5: key "anonymous-auth" already set in map". Trying more permissive conversion.
✓ Writing configuration 📜
✓ Starting control-plane 🕹️
✓ Installing CNI 🔌
✓ Installing StorageClass 💾
Set kubectl context to "kind-kind"
You can now use your cluster with:
kubectl cluster-info --context kind-kind
Thanks for using kind! 😊The warning messes up the output a little bit though. Maybe there is a better way to log this error (?) This change would not impact existing malformed patches and would reflect the current behaviour of |
stmcginnis
left a comment
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.
A couple small things that will cause CI failure.
Not sure if we have a better way to get the logger instance. I know some people using kind as a library, so I don't love changing the method signatures. But if that's what we have to do...
|
I didn't like changing the signatures of the functions either. Especially for such a small change. But I couldn't really find a better way. |
|
/ok-to-test @BenTheElder @aojea what do you think about the method signature change? I think it may be worth it to have this output. I actually have run into an instance where some templating errors were duplicating keys and it was not at all obvious why the resulting cluster wasn't configured right. |
|
+1 to strict parsing, I got bitted several times because of that and it takes a lot of time to figure out the problem @BenTheElder is the best person for the plumbing of the logger |
Currently when yamls with duplicate key entries are used for config patches, neither a warning nor an error message is displayed. For example using this malformed patch (See duplicate key in the last line) :
with
kind create cluster --config ./kind-config.yaml -v=9will result in the followingkubeadm.config(only relavant lines are shown):kubeletExtraArgs: anonymous-auth: "false"This PR contains a change to use
YAMLToJSONStrictinstead of the more relaxedYAMLToJSON. I also added a test case for an example with a duplicate key.