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: support openresty-1.25.3.1 #10887

Merged
merged 33 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d60428c
chore: upgrade openresty-1.25.3.1
zll600 Jan 30, 2024
e84b875
fix: remove trailing whitspace
zll600 Jan 30, 2024
c22ad18
fix: ci lint
zll600 Jan 30, 2024
be00c28
fix: ci lint
zll600 Jan 30, 2024
4ed4446
fix: enable_http2
zll600 Jan 30, 2024
494c174
fix: enable_http2
zll600 Jan 30, 2024
0108c5f
fix: enable_http2
zll600 Jan 30, 2024
93c7daa
fix: ci lint
zll600 Feb 1, 2024
7d125b2
fix: cli test
zll600 Feb 1, 2024
3c8dcae
fix: cli test
zll600 Feb 1, 2024
8e35feb
fix: http2 with content-length header
zll600 Feb 2, 2024
ce59af7
fix: ext-plugin
zll600 Feb 2, 2024
db03194
fix: remove server ssl port in upstream-tls.t
zll600 Feb 3, 2024
9fcb781
fix: enable proxy_ssl in stream proxy
zll600 Feb 4, 2024
bcc2ea5
Revert "fix: enable proxy_ssl in stream proxy"
zll600 Feb 5, 2024
7361f7b
chore: update
zll600 Feb 5, 2024
1422663
fix: update t/stream-node/upstream.t
zll600 Feb 5, 2024
39601f2
chore: add comment
zll600 Feb 5, 2024
ddc631f
fix: spawn sub-process in timer
zll600 Feb 6, 2024
c6b71fe
chore: cleanup http2
zll600 Feb 8, 2024
f979676
chore: cleanup
zll600 Feb 8, 2024
ef98f70
fix: lint error
zll600 Feb 20, 2024
22d46db
chore: grep 'http2 on'
zll600 Feb 20, 2024
1dd968c
chore: use apisix-runtime/1.2.0
zll600 Feb 21, 2024
9736157
chore: grep 'http2 on'
zll600 Feb 21, 2024
dabfb96
Merge branch 'master' into upgrade_openresty-1.25.3.1
zll600 Feb 21, 2024
25fd383
chore: test ci
zll600 Feb 21, 2024
4eadeca
chore: test ci
zll600 Feb 21, 2024
fbae45e
chore(ci): disable gm ci
zll600 Feb 22, 2024
e184acf
chore: revert install_apisix_runtime
zll600 Feb 23, 2024
69ef089
chore: report 400 for http2/3 request without content-length header
zll600 Feb 23, 2024
dc3c05c
fix: lint error
zll600 Feb 23, 2024
ff028e4
Merge remote-tracking branch 'apisix/master' into upgrade_openresty-1…
zll600 Feb 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions apisix/cli/ngx_tpl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -626,12 +626,15 @@ http {
{% end %}

server {
{% if enable_http2 then %}
http2 on;
zll600 marked this conversation as resolved.
Show resolved Hide resolved
{% end %}
{% for _, item in ipairs(node_listen) do %}
listen {* item.ip *}:{* item.port *} default_server {% if item.enable_http2 then %} http2 {% end %} {% if enable_reuseport then %} reuseport {% end %};
listen {* item.ip *}:{* item.port *} default_server {% if enable_reuseport then %} reuseport {% end %};
{% end %}
{% if ssl.enable then %}
{% for _, item in ipairs(ssl.listen) do %}
listen {* item.ip *}:{* item.port *} ssl default_server {% if item.enable_http2 then %} http2 {% end %} {% if enable_reuseport then %} reuseport {% end %};
listen {* item.ip *}:{* item.port *} ssl default_server {% if enable_reuseport then %} reuseport {% end %};
{% end %}
{% end %}
{% if proxy_protocol and proxy_protocol.listen_http_port then %}
Expand Down
11 changes: 11 additions & 0 deletions apisix/core/request.lua
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,17 @@ function _M.get_body(max_size, ctx)
end
end

-- TODO: solve this issue correctly.
local var = ctx and ctx.var or ngx.var
local content_length = tonumber(var.http_content_length) or 0
if (var.server_protocol == "HTTP/2.0" or var.server_protocol == "HTTP/3.0")
and content_length == 0 then
-- Due to the stream processing feature of HTTP/2 or HTTP/3,
-- this api could potentially block the entire request. Therefore,
-- this api is effective only when HTTP/2 or HTTP/3 requests send content-length header.
-- For requests with versions lower than HTTP/2, this api can still be used without any problems.
return nil
end
zll600 marked this conversation as resolved.
Show resolved Hide resolved
req_read_body()

local req_body = req_get_body_data()
Expand Down
20 changes: 12 additions & 8 deletions apisix/plugins/ext-plugin/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -968,15 +968,13 @@ local function setup_runner(cmd)
end

runner = nil
-- TODO: fix this correctly.
-- local ok, err = events:post(events_list._source, events_list.runner_exit)
-- if not ok then
-- core.log.error("post event failure with ", events_list._source, ", error: ", err)
-- end

local ok, err = events:post(events_list._source, events_list.runner_exit)
if not ok then
core.log.error("post event failure with ", events_list._source, ", error: ", err)
end

core.log.warn("respawn runner 3 seconds later with cmd: ", core.json.encode(cmd))
core.utils.sleep(3)
core.log.warn("respawning new runner...")
core.log.warn("respawn runner with cmd: ", core.json.encode(cmd))
runner = spawn_proc(cmd)
end
end)
Expand Down Expand Up @@ -1015,6 +1013,12 @@ function _M.exit_worker()
local num = resty_signal.signum("TERM")
runner:kill(num)

-- TODO: fix this correctly.
local ok, err = events:post(events_list._source, events_list.runner_exit)
if not ok then
core.log.error("post event failure with ", events_list._source, ", error: ", err)
end

-- give 1s to clean up the mess
core.os.waitpid(pid, 1)
-- then we KILL it via gc finalizer
Expand Down
5 changes: 1 addition & 4 deletions ci/centos7-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ install_dependencies() {
yum install -y yum-utils && yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
yum install -y openresty-pcre-devel openresty-zlib-devel

export runtime_version=${APISIX_RUNTIME}
wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh"
chmod +x build-apisix-runtime.sh
./build-apisix-runtime.sh latest
zll600 marked this conversation as resolved.
Show resolved Hide resolved
install_apisix_runtime
curl -o /usr/local/openresty/openssl3/ssl/openssl.cnf \
https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/conf/openssl3/openssl.cnf

Expand Down
8 changes: 8 additions & 0 deletions ci/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ install_curl () {
curl -V
}

install_apisix_runtime() {
export runtime_version=${APISIX_RUNTIME}
# wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh"
wget "https://raw.githubusercontent.com/zll600/apisix-build-tools/upgrade_openresty-1.25.3.1/build-apisix-runtime.sh"
zll600 marked this conversation as resolved.
Show resolved Hide resolved
chmod +x build-apisix-runtime.sh
./build-apisix-runtime.sh latest
}

install_grpcurl () {
# For more versions, visit https://github.com/fullstorydev/grpcurl/releases
GRPCURL_VERSION="1.8.5"
Expand Down
5 changes: 1 addition & 4 deletions ci/linux-install-openresty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ if [ "$OPENRESTY_VERSION" == "source" ]; then
fi
fi

export runtime_version=${APISIX_RUNTIME}
wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh"
chmod +x build-apisix-runtime.sh
./build-apisix-runtime.sh latest
install_apisix_runtime

if [ ! "$ENABLE_FIPS" == "true" ]; then
curl -o /usr/local/openresty/openssl3/ssl/openssl.cnf \
Expand Down
5 changes: 1 addition & 4 deletions ci/redhat-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ install_dependencies() {
yum install -y yum-utils && yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
yum install -y openresty-pcre-devel openresty-zlib-devel

export runtime_version=${APISIX_RUNTIME}
wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh"
chmod +x build-apisix-runtime.sh
./build-apisix-runtime.sh latest
install_apisix_runtime
curl -o /usr/local/openresty/openssl3/ssl/openssl.cnf \
https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/conf/openssl3/openssl.cnf

Expand Down
1 change: 1 addition & 0 deletions conf/config-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#

apisix:
enable_http2: true # only for test.
# node_listen: 9080 # APISIX listening port.
node_listen: # APISIX listening ports.
- 9080
Expand Down
3 changes: 2 additions & 1 deletion t/APISIX.pm
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,8 @@ _EOC_
$config .= <<_EOC_;
$ipv6_listen_conf

listen 1994 ssl http2;
listen 1994 ssl;
http2 on;
ssl_certificate cert/apisix.crt;
ssl_certificate_key cert/apisix.key;
lua_ssl_trusted_certificate cert/apisix.crt;
Expand Down
9 changes: 5 additions & 4 deletions t/cli/test_main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ echo "passed: support multiple ports listen in http and https"

echo "
apisix:
enable_http2: true
node_listen:
- ip: 127.0.0.1
port: 9081
Expand All @@ -152,8 +153,8 @@ if [ $count_http_specific_ip -ne 2 ]; then
exit 1
fi

count_http_specific_ip_and_enable_http2=`grep -c "listen 127.0.0..:908. default_server http2" conf/nginx.conf || true`
if [ $count_http_specific_ip_and_enable_http2 -ne 1 ]; then
count_http_specific_ip_and_enable_http2=`grep -c "listen 127.0.0..:908. default_server" conf/nginx.conf || true`
if [ $count_http_specific_ip_and_enable_http2 -ne 2 ]; then
echo "failed: failed to support specific IP and enable http2 listen in http"
exit 1
fi
Expand All @@ -164,8 +165,8 @@ if [ $count_https_specific_ip -ne 2 ]; then
exit 1
fi

count_https_specific_ip_and_enable_http2=`grep -c "listen 127.0.0..:944. ssl default_server http2" conf/nginx.conf || true`
if [ $count_https_specific_ip_and_enable_http2 -ne 1 ]; then
count_https_specific_ip_and_enable_http2=`grep -c "listen 127.0.0..:944. ssl default_server" conf/nginx.conf || true`
if [ $count_https_specific_ip_and_enable_http2 -ne 2 ]; then
zll600 marked this conversation as resolved.
Show resolved Hide resolved
echo "failed: failed to support specific IP and enable http2 listen in https"
exit 1
fi
Expand Down
1 change: 1 addition & 0 deletions t/core/config-default.t
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ node_listen: [1985,1986]
=== TEST 6: support listen multiple ports with array table
--- yaml_config
apisix:
enable_http2: true
node_listen:
- port: 1985
enable_http2: true
Expand Down
3 changes: 2 additions & 1 deletion t/plugin/ext-plugin/sanity.t
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ EXPIRE 3600
}
--- error_log
runner exited with reason: exit, status: 111
respawn runner 3 seconds later with cmd: ["t/plugin/ext-plugin/runner.sh","0.1"]
respawn runner with cmd: ["t/plugin/ext-plugin/runner.sh","0.1"]



Expand Down Expand Up @@ -297,6 +297,7 @@ receiving rpc type: 1 data length:
--- error_log
flush conf token lrucache
flush conf token in shared dict
--- SKIP



Expand Down
2 changes: 1 addition & 1 deletion t/plugin/proxy-rewrite2.t
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ GET /echo
X-Forwarded-Proto: http
X-Forwarded-Proto: grpc
--- response_headers
X-Forwarded-Proto: http
X-Forwarded-Proto: http, grpc
zll600 marked this conversation as resolved.
Show resolved Hide resolved



Expand Down
2 changes: 1 addition & 1 deletion t/stream-node/upstream-tls.t
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ hello apisix_backend
local ssl_key = t.read_file("t/certs/apisix.key")
local data = {
cert = ssl_cert, key = ssl_key,
sni = "test.com",
snis = { "test.com" },
zll600 marked this conversation as resolved.
Show resolved Hide resolved
}
local code, body = t.test('/apisix/admin/ssls/1',
ngx.HTTP_PUT,
Expand Down
3 changes: 2 additions & 1 deletion utils/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ function multi_distro_uninstallation() {

function install_apisix_runtime() {
export runtime_version=${APISIX_RUNTIME:?}
wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh"
# wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh"
wget "https://raw.githubusercontent.com/zll600/apisix-build-tools/upgrade_openresty-1.25.3.1/build-apisix-runtime.sh"
zll600 marked this conversation as resolved.
Show resolved Hide resolved
chmod +x build-apisix-runtime.sh
./build-apisix-runtime.sh latest
rm build-apisix-runtime.sh
Expand Down
Loading