Skip to content

Conversation

@dmcgowan
Copy link
Member

Updates host file parsing to use new v2 method rather than the removed toml.Tree.

@k8s-ci-robot
Copy link

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@dmcgowan
Copy link
Member Author

FYI @pelletier, if I properly attributed your solution

Updates host file parsing to use new v2 method rather than the removed
toml.Tree.

Signed-off-by: Derek McGowan <derek@mcg.dev>
@dmcgowan
Copy link
Member Author

Removed the "DisallowUnknownFields" because the CRI tests will fail. I didn't look into it more but seems likely we have some bad test configuration we should look at and consider enabling it. Also when configuration fails the error isn't super clear now.

@dmcgowan dmcgowan marked this pull request as ready for review September 22, 2023 23:34
@AkihiroSuda
Copy link
Member

Removed the "DisallowUnknownFields" because the CRI tests will fail.

This seems regression.

Can we at least print a warning when an unknown field is present in a toml?

if err := file.Unmarshal(config); err != nil {
// TODO: Add DisallowUnknownFields, requires better testing and bubbling errors
if err := toml.NewDecoder(f).Decode(config); err != nil {
return nil, fmt.Errorf("failed to unmarshal TOML: %w", err)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just in case you don't already know, you can type-assert the error returned by Decode into a toml.DecodeError, which allows you to print a more human friendly error (example).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, added better error handling using the toml error types, thanks.

@dmcgowan
Copy link
Member Author

dmcgowan commented Sep 25, 2023

This seems regression.

Not a regression, they were ignored before. I added a warning log. Now it will try to parse disallowing the unknown fields, catch the error, log the unknown fields, then try again allowing the unknown fields.

Add error log for failure to parse toml

Signed-off-by: Derek McGowan <derek@mcg.dev>
@djdongjin
Copy link
Member

/cherrypick release/1.7

@k8s-infra-cherrypick-robot

@djdongjin: #9131 failed to apply on top of branch "release/1.7":

Applying: Update go-toml to v2
.git/rebase-apply/patch:7841: trailing whitespace.
	    
.git/rebase-apply/patch:7884: space before tab in indent.
    	cp -r . "${dir}/"
.git/rebase-apply/patch:7978: space before tab in indent.
     	target="${1?Need to provide a target branch argument}"
error: patch failed: vendor/github.com/pelletier/go-toml/example-crlf.toml:1
error: vendor/github.com/pelletier/go-toml/example-crlf.toml: patch does not apply
error: Did you hand edit your patch?
It does not apply to blobs recorded in its index.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Using index info to reconstruct a base tree...
M	go.mod
M	go.sum
M	integration/client/go.mod
M	integration/client/go.sum
M	integration/images/image_list.go
M	pkg/cri/config/config.go
M	pkg/cri/config/config_unix.go
M	pkg/cri/sbserver/helpers.go
M	pkg/cri/sbserver/helpers_test.go
M	pkg/cri/server/helpers.go
M	pkg/cri/server/helpers_test.go
M	remotes/docker/config/hosts.go
M	remotes/docker/config/hosts_test.go
M	services/server/config/config.go
M	vendor/modules.txt
Patch failed at 0001 Update go-toml to v2

Details

In response to this:

/cherrypick release/1.7

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants