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

chore(cluster) head request to check wrpc endpoint #8834

Merged
merged 23 commits into from
May 30, 2022

Conversation

chronolaw
Copy link
Contributor

@chronolaw chronolaw commented May 20, 2022

Summary

We do not use /version-handshake endpoint, just send a simple HEAD request to /v1/wrpc,
If it works then we use wrpc, else we fall back to websocket + json.

If this PR is merged, I will remove the code and test case of version_negotiation.
Now I just keep it for compatibility.

Full changelog

  • Add a new function head_request_version in version_negotiation/init.lua
  • Change the behavior of functioin request_version_negotiation
  • Check the result in init_worker

@chronolaw chronolaw requested a review from a team as a code owner May 20, 2022 11:57
@javierguerragiraldez
Copy link
Contributor

this has the same issue that forced us to move version negotiation as a wRPC service and not as a HTTP request: the websocket and http client libraries won't use the same connection, so there's no guarantee both will go to the same server.

PR #8775 implements the inline negotiation and does the equivalent of this PR: "try the wRPC connection and fall back to old protocol if it can't connect"

@dndx
Copy link
Member

dndx commented May 24, 2022

@javierguerragiraldez What is the advantage of "keeping the connection on the same backend server". It seems to be very fragile and I don't know why would anyone want to deploy their CP cluster this way.

@javierguerragiraldez
Copy link
Contributor

@javierguerragiraldez What is the advantage of "keeping the connection on the same backend server".

Otherwise it requires shared state even before establishing the connection, as the CP has to carry the negotiation result from one event to another. If there's no guarantee that it's the same CP node, it has to be in a database.

When it's part of the wRPC itself, on the other hand, it seamlessly activates the right services (and version) for the connection, without any convoluted state management.

@pull-request-size pull-request-size bot added size/L and removed size/M labels May 25, 2022
@chronolaw chronolaw changed the title chore(cluster) head request to version negotiation chore(cluster) head request to check wrpc endpoint May 26, 2022
@chronolaw chronolaw force-pushed the chore/test_version_negotiation branch from 5717f2f to 65ab467 Compare May 27, 2022 00:52
@chronolaw chronolaw force-pushed the chore/test_version_negotiation branch from 65ab467 to df6da6b Compare May 27, 2022 08:36
kong-2.8.0-0.rockspec Outdated Show resolved Hide resolved
kong/clustering/wrpc_check.lua Outdated Show resolved Hide resolved
spec/02-integration/09-hybrid_mode/01-sync_spec.lua Outdated Show resolved Hide resolved
Comment on lines 210 to 211
--- detect '/v1/wrpc' endpoint
--- if there is no '/v1/wrpc', fallback to websocket + json
Copy link
Member

Choose a reason for hiding this comment

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

This documentation is not 100% accurate, it describes the goal, but not what this function does.

Suggested change
--- detect '/v1/wrpc' endpoint
--- if there is no '/v1/wrpc', fallback to websocket + json
--- Return the highest supported Hybrid mode protocol version.

Also, does this needs to be inside init.lua? The CP shouldn't need this functionality.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I consider moving it to utils.lua, but it may cause conflict with PR #8861.
So I want to do it in #8861, Do you think it is OK?

Copy link
Member

Choose a reason for hiding this comment

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

Could it be moved to wrpc_data_plane.lua?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is not suitable for wrpc_data_plane.lua, because at this point we have not decided which module will be required.

spec/02-integration/09-hybrid_mode/01-sync_spec.lua Outdated Show resolved Hide resolved
spec/helpers.lua Outdated Show resolved Hide resolved
return "v1" -- wrpc
end


function _M:request_version_negotiation()
Copy link
Member

Choose a reason for hiding this comment

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

Discussed with @chronolaw offline, this should probably be removed as the name is misleading.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@dndx dndx merged commit d851c3f into master May 30, 2022
@dndx dndx deleted the chore/test_version_negotiation branch May 30, 2022 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants