Skip to content

Commit f81a386

Browse files
authored
feat: release apisix 3.2.1 (#9559)
1 parent 626ec62 commit f81a386

29 files changed

+804
-279
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ jobs:
8383
echo "type=last" >>$GITHUB_OUTPUT
8484
fi
8585
86+
- name: Free disk space
87+
run: |
88+
bash ./ci/free_disk_space.sh
89+
8690
- name: Linux launch common services
8791
run: |
8892
make ci-env-up project_compose_ci=ci/pod/docker-compose.common.yml
@@ -114,9 +118,12 @@ jobs:
114118
if [[ -f docker-images-backup/apisix-images.tar ]]; then
115119
[[ ${{ steps.test_env.outputs.type }} != first ]] && sudo ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh before
116120
docker load --input docker-images-backup/apisix-images.tar
121+
echo "loaded docker images"
122+
123+
# preserve storage space
117124
rm docker-images-backup/apisix-images.tar
125+
118126
make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ steps.test_env.outputs.type }}.yml
119-
echo "loaded docker images"
120127
if [[ ${{ steps.test_env.outputs.type }} != first ]]; then
121128
sudo ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh after
122129
fi
@@ -168,8 +175,6 @@ jobs:
168175
- if: ${{ steps.cache-images.outputs.cache-hit != 'true' }}
169176
name: Save docker images
170177
run: |
171-
# free disk space
172-
bash ./ci/free_disk_space.sh
173178
echo "start backing up, $(date)"
174179
bash ./ci/backup-docker-images.sh ${{ steps.test_env.outputs.type }}
175180
echo "backup done, $(date)"

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ title: Changelog
2323

2424
## Table of Contents
2525

26+
- [3.2.1](#321)
2627
- [3.2.0](#320)
2728
- [3.1.0](#310)
2829
- [3.0.0](#300)
@@ -67,6 +68,16 @@ title: Changelog
6768
- [0.7.0](#070)
6869
- [0.6.0](#060)
6970

71+
## 3.2.1
72+
73+
### Bugfix
74+
75+
- Fix invalidate cache in core.request.add_header and fix some calls [#8824](https://github.com/apache/apisix/pull/8824)
76+
- Fix etcd data sync exception [#8493](https://github.com/apache/apisix/pull/8493)
77+
- Fix high cpu and memory usage cause by healthcheck [#9016](https://github.com/apache/apisix/pull/9016)
78+
- Prevent non-`127.0.0.0/24` to access admin api with empty admin_key [#9146](https://github.com/apache/apisix/pull/9146)
79+
- Fix(batch-requests): read trailer headers if exist [#9289](https://github.com/apache/apisix/pull/9289)
80+
7081
## 3.2.0
7182

7283
### Change

apisix/cli/ops.lua

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,9 @@ local function init(env)
185185
local checked_admin_key = false
186186
local allow_admin = yaml_conf.deployment.admin and
187187
yaml_conf.deployment.admin.allow_admin
188-
if yaml_conf.apisix.enable_admin and allow_admin then
189-
for _, allow_ip in ipairs(allow_admin) do
190-
if allow_ip == "127.0.0.0/24" then
191-
checked_admin_key = true
192-
end
193-
end
188+
if yaml_conf.apisix.enable_admin and allow_admin
189+
and #allow_admin == 1 and allow_admin[1] == "127.0.0.0/24" then
190+
checked_admin_key = true
194191
end
195192

196193
if yaml_conf.apisix.enable_admin and not checked_admin_key then

apisix/core/config_util.lua

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,24 @@ function _M.cancel_clean_handler(item, idx, fire)
8888
end
8989

9090
core_tab.remove(item.clean_handlers, pos)
91-
if fire then
91+
if not fire then
92+
return
93+
end
94+
95+
if f then
9296
f(item)
97+
else
98+
log.error("The function used to clear the health checker is nil, please check")
9399
end
94100
end
95101

96102

97103
-- fire all clean handlers added by add_clean_handler.
98104
function _M.fire_all_clean_handlers(item)
105+
-- When the key is deleted, the item will be set to false.
106+
if not item then
107+
return
108+
end
99109
if not item.clean_handlers then
100110
return
101111
end

apisix/core/request.lua

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ local req_get_body_file = ngx.req.get_body_file
4242
local req_get_post_args = ngx.req.get_post_args
4343
local req_get_uri_args = ngx.req.get_uri_args
4444
local req_set_uri_args = ngx.req.set_uri_args
45+
local table_insert = table.insert
46+
local req_set_header = ngx.req.set_header
4547

4648

4749
local _M = {}
@@ -108,16 +110,19 @@ function _M.header(ctx, name)
108110
return _headers(ctx)[name]
109111
end
110112

111-
112-
function _M.set_header(ctx, header_name, header_value)
113+
local function modify_header(ctx, header_name, header_value, override)
113114
if type(ctx) == "string" then
114115
-- It would be simpler to keep compatibility if we put 'ctx'
115116
-- after 'header_value', but the style is too ugly!
116117
header_value = header_name
117118
header_name = ctx
118119
ctx = nil
119120

120-
log.warn("DEPRECATED: use set_header(ctx, header_name, header_value) instead")
121+
if override then
122+
log.warn("DEPRECATED: use set_header(ctx, header_name, header_value) instead")
123+
else
124+
log.warn("DEPRECATED: use add_header(ctx, header_name, header_value) instead")
125+
end
121126
end
122127

123128
local err
@@ -131,26 +136,37 @@ function _M.set_header(ctx, header_name, header_value)
131136
changed = a6_request.is_request_header_set()
132137
end
133138

134-
ngx.req.set_header(header_name, header_value)
139+
if override then
140+
req_set_header(header_name, header_value)
141+
else
142+
req_add_header(header_name, header_value)
143+
end
135144

136145
if is_apisix_or and not changed then
137146
-- if the headers are not changed before,
138147
-- we can only update part of the cache instead of invalidating the whole
139148
a6_request.clear_request_header()
140149
if ctx and ctx.headers then
141-
ctx.headers[header_name] = header_value
150+
if override or not ctx.headers[header_name] then
151+
ctx.headers[header_name] = header_value
152+
else
153+
local values = ctx.headers[header_name]
154+
if type(values) == "table" then
155+
table_insert(values, header_value)
156+
else
157+
ctx.headers[header_name] = {values, header_value}
158+
end
159+
end
142160
end
143161
end
144162
end
145163

146-
function _M.add_header(header_name, header_value)
147-
local err
148-
header_name, err = _validate_header_name(header_name)
149-
if err then
150-
error(err)
151-
end
164+
function _M.set_header(ctx, header_name, header_value)
165+
modify_header(ctx, header_name, header_value, true)
166+
end
152167

153-
req_add_header(header_name, header_value)
168+
function _M.add_header(ctx, header_name, header_value)
169+
modify_header(ctx, header_name, header_value, false)
154170
end
155171

156172
-- return the remote address of client which directly connecting to APISIX.

apisix/core/version.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@
2020
-- @module core.version
2121

2222
return {
23-
VERSION = "3.2.0"
23+
VERSION = "3.2.1"
2424
}

apisix/plugins/batch-requests.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,14 @@ local function batch_requests(ctx)
275275
headers = resp.headers,
276276
}
277277
if resp.has_body then
278-
sub_resp.body = resp:read_body()
278+
local err
279+
sub_resp.body, err = resp:read_body()
280+
if err then
281+
sub_resp.read_body_err = err
282+
core.log.error("read pipeline response body failed: ", err)
283+
else
284+
resp:read_trailers()
285+
end
279286
end
280287
core.table.insert(aggregated_resp, sub_resp)
281288
end

apisix/plugins/proxy-rewrite.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,18 +327,18 @@ function _M.rewrite(conf, ctx)
327327
for i = 1, field_cnt, 2 do
328328
local val = core.utils.resolve_var(hdr_op.add[i + 1], ctx.var)
329329
local header = hdr_op.add[i]
330-
core.request.add_header(header, val)
330+
core.request.add_header(ctx, header, val)
331331
end
332332

333333
local field_cnt = #hdr_op.set
334334
for i = 1, field_cnt, 2 do
335335
local val = core.utils.resolve_var(hdr_op.set[i + 1], ctx.var)
336-
core.request.set_header(hdr_op.set[i], val)
336+
core.request.set_header(ctx, hdr_op.set[i], val)
337337
end
338338

339339
local field_cnt = #hdr_op.remove
340340
for i = 1, field_cnt do
341-
core.request.set_header(hdr_op.remove[i], nil)
341+
core.request.set_header(ctx, hdr_op.remove[i], nil)
342342
end
343343

344344
end

apisix/upstream.lua

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ local error = error
2323
local tostring = tostring
2424
local ipairs = ipairs
2525
local pairs = pairs
26+
local pcall = pcall
2627
local ngx_var = ngx.var
2728
local is_http = ngx.config.subsystem == "http"
2829
local upstreams
@@ -103,6 +104,12 @@ local function create_checker(upstream)
103104
return healthcheck_parent.checker
104105
end
105106

107+
if upstream.is_creating_checker then
108+
core.log.info("another request is creating new checker")
109+
return nil
110+
end
111+
upstream.is_creating_checker = true
112+
106113
local checker, err = healthcheck.new({
107114
name = get_healthchecker_name(healthcheck_parent),
108115
shm_name = "upstream-healthcheck",
@@ -111,20 +118,24 @@ local function create_checker(upstream)
111118

112119
if not checker then
113120
core.log.error("fail to create healthcheck instance: ", err)
121+
upstream.is_creating_checker = nil
114122
return nil
115123
end
116124

117125
if healthcheck_parent.checker then
118-
core.config_util.cancel_clean_handler(healthcheck_parent,
126+
local ok, err = pcall(core.config_util.cancel_clean_handler, healthcheck_parent,
119127
healthcheck_parent.checker_idx, true)
128+
if not ok then
129+
core.log.error("cancel clean handler error: ", err)
130+
end
120131
end
121132

122133
core.log.info("create new checker: ", tostring(checker))
123134

124135
local host = upstream.checks and upstream.checks.active and upstream.checks.active.host
125136
local port = upstream.checks and upstream.checks.active and upstream.checks.active.port
126137
local up_hdr = upstream.pass_host == "rewrite" and upstream.upstream_host
127-
local use_node_hdr = upstream.pass_host == "node"
138+
local use_node_hdr = upstream.pass_host == "node" or nil
128139
for _, node in ipairs(upstream.nodes) do
129140
local host_hdr = up_hdr or (use_node_hdr and node.domain)
130141
local ok, err = checker:add_target(node.host, port or node.port, host,
@@ -140,6 +151,8 @@ local function create_checker(upstream)
140151
healthcheck_parent.checker_idx =
141152
core.config_util.add_clean_handler(healthcheck_parent, release_checker)
142153

154+
upstream.is_creating_checker = nil
155+
143156
return checker
144157
end
145158

ci/linux_apisix_master_luarocks_runner.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ script() {
3939
cp -r ../utils ./
4040

4141
# install APISIX by luarocks
42-
sudo luarocks install $APISIX_MAIN > build.log 2>&1 || (cat build.log && exit 1)
42+
luarocks install $APISIX_MAIN > build.log 2>&1 || (cat build.log && exit 1)
4343
cp ../bin/apisix /usr/local/bin/apisix
4444

4545
# show install files

0 commit comments

Comments
 (0)