Skip to content
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

fix(kumactl): npe when creating new core resources #9593

Merged

Conversation

michaelbeaumont
Copy link
Contributor

@michaelbeaumont michaelbeaumont commented Mar 13, 2024

Without IsPluginOriginated the deserialization expects a ProtoMessage:

$ kumactl apply -f meshservice.yaml
panic: interface conversion: *v1alpha1.MeshService is not protoreflect.ProtoMessage: missing method ProtoReflect

goroutine 1 [running]:
github.com/kumahq/kuma/pkg/core/resources/model/rest/unversioned.(*Resource).UnmarshalJSON(0xc000086180, {0xc000925400, 0x3f, 0x200})
	github.com/kumahq/kuma/pkg/core/resources/model/rest/unversioned/resource.go:72 +0xc9
encoding/json.(*decodeState).object(0xc000379068, {0x266e2c0?, 0xc0002ffa90?, 0xc000999408?})
	encoding/json/decode.go:604 +0x6cc
encoding/json.(*decodeState).value(0xc000379068, {0x266e2c0?, 0xc0002ffa90?, 0xc000999458?})
	encoding/json/decode.go:374 +0x3e
encoding/json.(*decodeState).unmarshal(0xc000379068, {0x266e2c0?, 0xc0002ffa90?})
	encoding/json/decode.go:181 +0x133
encoding/json.(*Decoder).Decode(0xc000379040, {0x266e2c0, 0xc0002ffa90})
	encoding/json/stream.go:73 +0x179
sigs.k8s.io/yaml.jsonUnmarshal({0x45220c0?, 0xc000879470}, {0x298ef20, 0xc000086180}, {0x0, 0x0, 0x0?})
	sigs.k8s.io/yaml@v1.4.0/yaml.go:94 +0xf6
sigs.k8s.io/yaml.unmarshal({0xc000a87200?, 0xd?, 0x0?}, {0x298ef20, 0xc000086180}, 0x0?, {0x0, 0x0, 0x0})
	sigs.k8s.io/yaml@v1.4.0/yaml.go:77 +0x18f
sigs.k8s.io/yaml.Unmarshal(...)
	sigs.k8s.io/yaml@v1.4.0/yaml.go:56
github.com/kumahq/kuma/pkg/core/resources/model/rest.glob..func1({0xc000a87200?, 0x4570ba0?, 0xc000894df8?}, {0x298ef20?, 0xc000086180?})
	github.com/kumahq/kuma/pkg/core/resources/model/rest/unmarshaller.go:21 +0x32
github.com/kumahq/kuma/pkg/core/resources/model/rest.(*unmarshaler).Unmarshal(0x61b6ca0, {0xc000a87200, _, _}, {{0x2d6234e, 0xb}, {0x4570ba0, 0x61cfeb0}, {0x4574dd0, 0x6231b80}, ...})
	github.com/kumahq/kuma/pkg/core/resources/model/rest/unmarshaller.go:82 +0x2f4
github.com/kumahq/kuma/pkg/core/resources/model/rest.(*unmarshaler).UnmarshalCore(0x61b6ca0, {0xc000a87200, 0x33, 0x40})
	github.com/kumahq/kuma/pkg/core/resources/model/rest/unmarshaller.go:54 +0x1ff
github.com/kumahq/kuma/app/kumactl/cmd/apply.NewApplyCmd.func1(0xc000ef6600, {0x0?, 0x0?, 0x0?})
	github.com/kumahq/kuma/app/kumactl/cmd/apply/apply.go:114 +0x51d
github.com/kumahq/kuma/app/kumactl/pkg/errors.FormatErrorWrapper.func1(0xc000ea1300?, {0xc000844560?, 0x4?, 0x2d55a0e?})
	github.com/kumahq/kuma/app/kumactl/pkg/errors/formatter.go:14 +0x1c
github.com/spf13/cobra.(*Command).execute(0xc000ef6600, {0xc000844540, 0x2, 0x2})
	github.com/spf13/cobra@v1.8.0/command.go:983 +0xabc
github.com/spf13/cobra.(*Command).ExecuteC(0xc000ef6300)
	github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/cobra@v1.8.0/command.go:1039
github.com/kumahq/kuma/app/kumactl/cmd.Execute()
	github.com/kumahq/kuma/app/kumactl/cmd/root.go:113 +0x18
main.main()
	github.com/kumahq/kuma/app/kumactl/main.go:6 +0xf

Checklist prior to review

  • Link to relevant issue as well as docs and UI issues --
  • This will not break child repos: it doesn't hardcode values (.e.g "kumahq" as a image registry) and it will work on Windows, system specific functions like syscall.Mkfifo have equivalent implementation on the other OS --
  • Tests (Unit test, E2E tests, manual test on universal and k8s) --
    • Don't forget ci/ labels to run additional/fewer tests
  • Do you need to update UPGRADE.md? --
  • Does it need to be backported according to the backporting policy? (this GH action will add "backport" label based on these file globs, if you want to prevent it from adding the "backport" label use no-backport-autolabel label) --

Signed-off-by: Mike Beaumont <mjboamail@gmail.com>
@michaelbeaumont michaelbeaumont requested a review from a team as a code owner March 13, 2024 13:51
@michaelbeaumont michaelbeaumont requested review from jijiechen and bartsmykla and removed request for a team March 13, 2024 13:51
Copy link
Contributor

@jakubdyszkiewicz jakubdyszkiewicz left a comment

Choose a reason for hiding this comment

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

I could use some more explanation why it fixes the problem.
Can we also cover this with unit test?

@michaelbeaumont
Copy link
Contributor Author

michaelbeaumont commented Mar 13, 2024

Can we also cover this with unit test?

Theoretically, but I'm not quite sure what that'd look like, we don't currently test code generation itself.
I guess we could call kumactl apply for every resource but this isn't really a problem with a particular resource, it's just the code generation being incorrect.

@michaelbeaumont michaelbeaumont merged commit ed827b4 into kumahq:master Mar 13, 2024
28 checks passed
@michaelbeaumont michaelbeaumont deleted the fix/disabled-core-kumactl branch March 13, 2024 20:44
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.

None yet

2 participants