Skip to content

Commit 2cbb9a2

Browse files
nic-6443jizhuozhi
authored andcommitted
fix: load full data during init_worker phase require a new apisix-runtime (apache#12678)
Signed-off-by: Nic <[email protected]>
1 parent 9437e84 commit 2cbb9a2

File tree

3 files changed

+49
-7
lines changed

3 files changed

+49
-7
lines changed

.requirements

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717

1818
APISIX_PACKAGE_NAME=apisix
1919

20-
APISIX_RUNTIME=1.3.2
20+
APISIX_RUNTIME=1.3.3
2121
APISIX_DASHBOARD_COMMIT=39be363cdbc5395d3163572c532be95f3dbad03a

t/cli/test_ci_only.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ git checkout conf/config.yaml
4949

5050
mkdir /root/apisix
5151

52-
cp -r ./* /root/apisix
52+
cp -R ./* /root/apisix
5353
cd /root/apisix
5454
make init
5555

t/cli/test_load_full_data_init_worker.sh

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,56 @@
1919

2020
. ./t/cli/common.sh
2121

22+
rm logs/error.log || true
23+
2224
git checkout conf/config.yaml
2325

2426
echo '
2527
apisix:
2628
worker_startup_time_threshold: 3
29+
nginx_config:
30+
worker_processes: 1
31+
http_configuration_snippet: |
32+
server {
33+
listen 1980;
34+
location /hello {
35+
return 200 "hello world";
36+
}
37+
}
2738
' > conf/config.yaml
2839

2940
make run
3041

3142
sleep 5
3243

44+
admin_key=$(yq '.deployment.admin.admin_key[0].key' conf/config.yaml | sed 's/"//g')
45+
curl -k -i http://127.0.0.1:9180/apisix/admin/routes/1 -H "X-API-KEY: $admin_key" -X PUT -d '
46+
{
47+
"uri": "/hello",
48+
"upstream": {
49+
"nodes": {
50+
"127.0.0.1:1980": 1
51+
},
52+
"scheme": "http",
53+
"type": "roundrobin"
54+
}
55+
}'
56+
57+
sleep 1
58+
59+
code=$(curl -v -k -i -m 20 -o /dev/null -s -w %{http_code} http://127.0.0.1:9080/hello)
60+
if [ ! $code -eq 200 ]; then
61+
echo "failed: request failed, http status $code"
62+
exit 1
63+
fi
64+
3365
MASTER_PID=$(cat logs/nginx.pid)
3466

35-
worker_pids=$(pgrep -P "$MASTER_PID" -f "nginx: worker process" || true)
67+
worker_pid=$(pgrep -P "$MASTER_PID" -f "nginx: worker process" || true)
3668

37-
if [ -n "$worker_pids" ]; then
38-
pid=$(echo "$worker_pids" | shuf -n 1)
39-
echo "killing worker $pid (master $MASTER_PID)"
40-
kill "$pid"
69+
if [ -n "$worker_pid" ]; then
70+
echo "killing worker $worker_pid (master $MASTER_PID)"
71+
kill "$worker_pid"
4172
else
4273
echo "failed: no worker process found for master $MASTER_PID"
4374
exit 1
@@ -50,6 +81,17 @@ if ! grep 'master process has been running for a long time, reloading the full c
5081
exit 1
5182
fi
5283

84+
if grep 'API disabled in the context of init_worker_by_lua' logs/error.log; then
85+
echo "failed: cannot access etcd in init_worker phase"
86+
exit 1
87+
fi
88+
89+
code=$(curl -v -k -i -m 20 -o /dev/null -s -w %{http_code} http://127.0.0.1:9080/hello)
90+
if [ ! $code -eq 200 ]; then
91+
echo "failed: request failed for new worker, http status $code"
92+
exit 1
93+
fi
94+
5395
echo "passed: load full configuration for new worker"
5496

5597
make stop

0 commit comments

Comments
 (0)