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

feat: traffic-split plugin support https #9115

Merged
merged 29 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0945b40
feat: add method that parse ip from /etc/hosts in high priority
Nov 14, 2022
faf3d97
Merge remote-tracking branch 'apache/master'
Nov 14, 2022
31379e4
Merge remote-tracking branch 'apache/master'
Nov 17, 2022
21569ce
feat: add method that parse ip from /etc/hosts in high priority
Nov 17, 2022
97b53ab
feat: add method that parse ip from /etc/hosts in high priority;
Nov 17, 2022
75896d5
Merge remote-tracking branch 'apache/master'
Nov 18, 2022
a6dbe19
feat: add method that parse ip from /etc/hosts in high priority; modi…
Nov 18, 2022
c6cd826
Merge remote-tracking branch 'apache/master'
Nov 18, 2022
7b90508
Merge remote-tracking branch 'apache/master'
Jan 6, 2023
f12e75b
Merge remote-tracking branch 'apache/master'
Mar 2, 2023
18f0772
Merge remote-tracking branch 'apache/master'
Mar 20, 2023
3842903
feat: traffic-split plugin can't proxy virtual upstream that schema i…
Mar 20, 2023
5ea121f
Merge remote-tracking branch 'apache/master'
Mar 28, 2023
e7f1a48
Merge remote-tracking branch 'apache/master'
Apr 1, 2023
8f9ceb2
feat: Adjusting unit tests
Apr 2, 2023
3afaaeb
Merge remote-tracking branch 'apache/master'
Apr 6, 2023
ae1058c
Merge remote-tracking branch 'apache/master'
Sep 5, 2023
c8426fe
feat: traffic-split plugin can't proxy virtual upstream that schema i…
Sep 5, 2023
e459d4c
add tests
shreemaan-abhishek Sep 5, 2023
d515336
revert unnecessary test case changes
shreemaan-abhishek Sep 5, 2023
d18f0b6
remove unneccessary changes
shreemaan-abhishek Sep 6, 2023
b23daef
unexport method
shreemaan-abhishek Sep 6, 2023
7af60dd
remove mistakenly commited lines
shreemaan-abhishek Sep 6, 2023
8a0236d
remove miscommited line
shreemaan-abhishek Sep 6, 2023
64347b1
unexport method
shreemaan-abhishek Sep 6, 2023
4eeced9
remove reference to non existing ssl resource
shreemaan-abhishek Sep 6, 2023
08f6479
set scheme
shreemaan-abhishek Sep 17, 2023
cb2e367
add scheme check
shreemaan-abhishek Sep 17, 2023
1acc511
use real upstream instead of upstream id
shreemaan-abhishek Sep 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion apisix/plugins/traffic-split.lua
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ local function set_upstream(upstream_info, ctx)
key = upstream_info.key,
nodes = new_nodes,
timeout = upstream_info.timeout,
scheme = upstream_info.scheme
}

local ok, err = upstream.check_schema(up_conf)
Expand All @@ -190,7 +191,9 @@ local function set_upstream(upstream_info, ctx)
end
core.log.info("upstream_key: ", upstream_key)
upstream.set(ctx, upstream_key, ctx.conf_version, up_conf)

if upstream_info.scheme == "https" then
upstream.set_scheme(ctx, up_conf)
end
return
end

Expand Down
2 changes: 1 addition & 1 deletion apisix/upstream.lua
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ local function set_upstream_scheme(ctx, upstream)

ctx.var["upstream_scheme"] = ctx.upstream_scheme
end

_M.set_scheme = set_upstream_scheme

local scheme_to_port = {
http = 80,
Expand Down
63 changes: 63 additions & 0 deletions t/plugin/traffic-split2.t
Original file line number Diff line number Diff line change
Expand Up @@ -799,3 +799,66 @@ GET /t
--- error_code: 500
--- error_log
failed to find upstream by id: invalid-id



=== TEST 21: use upstream with https scheme
Copy link
Contributor

Choose a reason for hiding this comment

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

The test case can pass without your pr

Copy link
Contributor

Choose a reason for hiding this comment

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

looks like using upstream_id supports https but using real upstream is not supported, I have pushed my changes now, please review.

--- config
location /t {
content_by_lua_block {
local json = require("toolkit.json")
local t = require("lib.test_admin")

local data = {
uri = "/hello",
plugins = {
["traffic-split"] = {
rules = {
{
match = { {
vars = { { "arg_scheme", "==", "https" } }
} },
weighted_upstreams = {
{
upstream = {
type = "roundrobin",
pass_host = "node",
nodes = {
["127.0.0.1:1983"] = 1,
},
scheme = "https"
},
weight = 1
}
}
}
}
}
},
upstream = {
type = "roundrobin",
nodes = {
["127.0.0.1:1980"] = 1
}
}
}

local code, body = t.test('/apisix/admin/routes/1',
ngx.HTTP_PUT,
json.encode(data)
)
if code >= 300 then
ngx.status = code
end
ngx.say(body)
}
}
--- response_body
passed



=== TEST 22: hit route
--- request
GET /hello?scheme=https
--- error_code: 200