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(clustering/rpc): support cluster_use_proxy option for clustering rpc protocol #13971

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

chobits
Copy link
Contributor

@chobits chobits commented Dec 3, 2024

Summary

The original hybrid mode connections like full sync (sync v1) support forward proxy via the option cluster_use_proxy. While clustering RPC protocol does not support this, this commit introduces this feature to RPC protocol.

Checklist

  • The Pull Request has tests
  • A changelog file has been created under changelog/unreleased/kong or skip-changelog label added on PR if changelog is unnecessary. README.md
  • There is a user-facing docs PR against https://github.com/Kong/docs.konghq.com - PUT DOCS PR HERE

Issue reference

Fix KAG-5555

@github-actions github-actions bot added core/clustering cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee labels Dec 3, 2024
@chobits chobits requested a review from chronolaw December 3, 2024 07:00
@pull-request-size pull-request-size bot added size/M and removed size/S labels Dec 3, 2024
Comment on lines +478 to +488
if self.conf.cluster_use_proxy then
local proxy_opts = parse_proxy_url(self.conf.proxy_server)
opts.proxy_opts = {
wss_proxy = proxy_opts.proxy_url,
wss_proxy_authorization = proxy_opts.proxy_authorization,
}

ngx_log(ngx_DEBUG, "[rpc] using proxy ", proxy_opts.proxy_url,
" to connect control plane")
end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Logic comes from kong/clustering//utils.lua: local ok, err = c:connect(uri, opts).

if conf.cluster_use_proxy then
local proxy_opts = parse_proxy_url(conf.proxy_server)
opts.proxy_opts = {
wss_proxy = proxy_opts.proxy_url,
wss_proxy_authorization = proxy_opts.proxy_authorization,
}
ngx_log(ngx_DEBUG, _log_prefix,
"using proxy ", proxy_opts.proxy_url, " to connect control plane")
end

@chobits chobits marked this pull request as draft December 3, 2024 07:50
@chobits chobits force-pushed the fix/rpc_cluster_use_proxy branch from 45c68b5 to 57bcb2c Compare December 4, 2024 02:17
@chobits chobits marked this pull request as ready for review December 4, 2024 02:17
@chobits
Copy link
Contributor Author

chobits commented Dec 4, 2024

record flakiness: https://github.com/Kong/kong/actions/runs/12151750267/job/33886933473?pr=13971, then rerun

Click to expand image

@chronolaw
Copy link
Contributor

Should we add a change log entry for this?

@chobits
Copy link
Contributor Author

chobits commented Dec 4, 2024

Should we add a change log entry for this?

I think we dont need a change log for this one, because incremental sync feature is not GA. This modifcation tries to backport original function to work on incremental sync

@chronolaw chronolaw changed the title fix(clustering/rpc) support cluster_use_proxy option for clustering rpc protocol fix(clustering/rpc): support cluster_use_proxy option for clustering rpc protocol Dec 4, 2024
Copy link
Contributor

@StarlightIbuki StarlightIbuki left a comment

Choose a reason for hiding this comment

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

Any tests?

@chobits
Copy link
Contributor Author

chobits commented Dec 5, 2024

Any tests?

The tests are here:

The following newly added tests try to test which protocol websocket connection uses.

image

[rpc] ... means the incremetnal sync is using forward proxy feature to transport the entities.
[clustering] ... means it tries to test the original forward proxy for full sync.

image

The following original test tries to verify whether the connect tunnel is created:
image

@chobits chobits closed this Dec 5, 2024
@chobits chobits reopened this Dec 5, 2024
@chobits chobits force-pushed the fix/rpc_cluster_use_proxy branch from 6fdbb59 to 5620a51 Compare December 9, 2024 07:46
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 core/clustering size/M skip-changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants