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(pluginsocket.proto): type for set_upstream #12727

Merged
merged 1 commit into from
Mar 13, 2024
Merged

Conversation

gszr
Copy link
Member

@gszr gszr commented Mar 12, 2024

Summary

Fix the return type for the .Service.SetUpstream external plugin PDK method.

Fixes issue Kong/go-pdk#114.

Sister PR: Kong/go-pdk#191

Issue reference

Fixes issue Kong/go-pdk#114.

gszr added a commit to Kong/go-pdk that referenced this pull request Mar 12, 2024
Fix the return type for the `.Service.SetUpstream` external plugin PDK
method.

Fixes issue #114.

Sister PR: Kong/kong#12727
Fix the return type for the `.Service.SetUpstream` external plugin PDK
method.

Fixes issue Kong/go-pdk#114.

Sister PR: Kong/go-pdk#191
@gszr gszr force-pushed the fix/pluginsocet-proto branch from 13bc72e to 66712fb Compare March 12, 2024 21:55
@gszr gszr requested review from locao and StarlightIbuki March 12, 2024 21:56
Copy link
Contributor

@nowNick nowNick left a comment

Choose a reason for hiding this comment

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

I jumped the gun a little bit with approval. Could you clarify this one question for me?

@@ -328,7 +328,7 @@ service Kong {
rpc Router_GetRoute(google.protobuf.Empty) returns (Route);
rpc Router_GetService(google.protobuf.Empty) returns (Service);

rpc Service_SetUpstream(String) returns (google.protobuf.Empty);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it work with only Bool ? The general PDK says that there are 2 values returned: (bool, string) - https://docs.konghq.com/gateway/latest/plugin-development/pdk/kong.service/#kongserviceset_upstreamhost

Copy link
Member Author

@gszr gszr Mar 13, 2024

Choose a reason for hiding this comment

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

Good question!
I have verified the change works for both cases.

Longer answer:
Although it fixes the behavior described in Kong/go-pdk#114, the go-pdk does not currently handle consistently the nil, err protocol adopted in the Lua PDK -- ie, most methods do not return the err on the Go PDK side (only other errors are reported, like connection errors, protobuf errors, etc). Also, on the Go PDK side the SetUpstream method does not return a boolean, only an error. Fixing this means an API breaking change has to be introduced, so this really needs to be done before we release v1.0.0, but not in the scope of this fix. I will add this to my future improvements notes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, ok! That makes sense. Thanks 👍 !

@nowNick nowNick self-requested a review March 13, 2024 11:45
Copy link
Contributor

@nowNick nowNick left a comment

Choose a reason for hiding this comment

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

Thanks for clarifying!

@gszr gszr merged commit 25b3317 into master Mar 13, 2024
26 checks passed
@gszr gszr deleted the fix/pluginsocet-proto branch March 13, 2024 16:25
gszr added a commit to Kong/go-pdk that referenced this pull request Mar 13, 2024
Fix the return type for the `.Service.SetUpstream` external plugin PDK
method.

Fixes issue #114.

Sister PR: Kong/kong#12727
gszr added a commit to Kong/go-pdk that referenced this pull request Mar 13, 2024
Fix the return type for the `.Service.SetUpstream` external plugin PDK
method.

Fixes issue #114.

Sister PR: Kong/kong#12727
gszr added a commit to Kong/go-pdk that referenced this pull request Mar 13, 2024
Fix the return type for the `.Service.SetUpstream` external plugin PDK
method.

Fixes issue #114.

Sister PR: Kong/kong#12727
@gszr gszr added the cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee label Apr 1, 2024
@team-gateway-bot
Copy link
Collaborator

Successfully created cherry-pick PR for master:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee size/XS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants