From 1c46c7995e4dc80fc00afc9f1ab25e2f4a7b4f96 Mon Sep 17 00:00:00 2001 From: Hazel6869 <1358508600@qq.com> Date: Tue, 11 Oct 2022 17:22:45 +0800 Subject: [PATCH 1/7] fix enable_cpu_affinity --- conf/config-default.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/config-default.yaml b/conf/config-default.yaml index 642d4e89de41..c2c5b3e72234 100755 --- a/conf/config-default.yaml +++ b/conf/config-default.yaml @@ -167,7 +167,7 @@ nginx_config: # config for render the template to generate n error_log: logs/error.log error_log_level: warn # warn,error worker_processes: auto # if you want use multiple cores in container, you can inject the number of cpu as environment variable "APISIX_WORKER_PROCESSES" - enable_cpu_affinity: true # enable cpu affinity, this is just work well only on physical machine + enable_cpu_affinity: false # enable cpu affinity, this is just work well only on physical machine worker_rlimit_nofile: 20480 # the number of files a worker process can open, should be larger than worker_connections worker_shutdown_timeout: 240s # timeout for a graceful shutdown of worker processes From 6de55a05e074b10694959e1b0b547317c6835537 Mon Sep 17 00:00:00 2001 From: Hazel6869 <1358508600@qq.com> Date: Wed, 12 Oct 2022 10:10:43 +0800 Subject: [PATCH 2/7] fix test --- t/cli/test_main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/cli/test_main.sh b/t/cli/test_main.sh index ea54c53b8425..375425ae7768 100755 --- a/t/cli/test_main.sh +++ b/t/cli/test_main.sh @@ -447,7 +447,7 @@ git checkout conf/config.yaml make init grep -E "worker_cpu_affinity" conf/nginx.conf > /dev/null -if [ ! $? -eq 0 ]; then +if [ ! $? -eq 1 ]; then echo "failed: nginx.conf file is missing worker_cpu_affinity configuration" exit 1 fi From c197996253bf52a91f113a857e203d6244b016f3 Mon Sep 17 00:00:00 2001 From: Hazel6869 <1358508600@qq.com> Date: Wed, 12 Oct 2022 11:55:08 +0800 Subject: [PATCH 3/7] fix test --- t/cli/test_main.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/t/cli/test_main.sh b/t/cli/test_main.sh index 375425ae7768..d54f5279482e 100755 --- a/t/cli/test_main.sh +++ b/t/cli/test_main.sh @@ -448,11 +448,11 @@ make init grep -E "worker_cpu_affinity" conf/nginx.conf > /dev/null if [ ! $? -eq 1 ]; then - echo "failed: nginx.conf file is missing worker_cpu_affinity configuration" + echo "failed: nginx.conf file is contains worker_cpu_affinity configuration" exit 1 fi -echo "passed: nginx.conf file contains worker_cpu_affinity configuration" +echo "passed: nginx.conf file missing worker_cpu_affinity configuration" # check the 'worker_shutdown_timeout' in 'nginx.conf' . @@ -564,7 +564,7 @@ nginx_config: make init count=`grep -c "worker_cpu_affinity" conf/nginx.conf || true` -if [ $count -ne 0 ]; then +if [ $count -ne 1 ]; then echo "failed: nginx.conf file found worker_cpu_affinity when disable it" exit 1 fi From e9993e782c273986b3f2d7fa6abb863f6f8fd8b9 Mon Sep 17 00:00:00 2001 From: Hazel6869 <1358508600@qq.com> Date: Wed, 12 Oct 2022 14:04:29 +0800 Subject: [PATCH 4/7] fix test --- t/cli/test_main.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/t/cli/test_main.sh b/t/cli/test_main.sh index d54f5279482e..8d6ab6d41413 100755 --- a/t/cli/test_main.sh +++ b/t/cli/test_main.sh @@ -446,13 +446,13 @@ git checkout conf/config.yaml make init -grep -E "worker_cpu_affinity" conf/nginx.conf > /dev/null -if [ ! $? -eq 1 ]; then - echo "failed: nginx.conf file is contains worker_cpu_affinity configuration" +count=`grep -c "worker_cpu_affinity" conf/nginx.conf || true` +if [ $count -ne 0 ]; then + echo "failed: nginx.conf file found worker_cpu_affinity when disable it" exit 1 fi -echo "passed: nginx.conf file missing worker_cpu_affinity configuration" +echo "passed: nginx.conf file disable cpu affinity" # check the 'worker_shutdown_timeout' in 'nginx.conf' . @@ -558,18 +558,18 @@ git checkout conf/config.yaml echo ' nginx_config: - enable_cpu_affinity: false + enable_cpu_affinity: true ' > conf/config.yaml make init -count=`grep -c "worker_cpu_affinity" conf/nginx.conf || true` -if [ $count -ne 1 ]; then - echo "failed: nginx.conf file found worker_cpu_affinity when disable it" +grep -E "worker_cpu_affinity" conf/nginx.conf > /dev/null +if [ ! $? -eq 0 ]; then + echo "failed: nginx.conf file is missing worker_cpu_affinity configuration" exit 1 fi -echo "passed: nginx.conf file disable cpu affinity" +echo "passed: nginx.conf file contains worker_cpu_affinity configuration" # set worker processes with env git checkout conf/config.yaml From d4b9d69fa3761d982724905746d5a21bc4736d7a Mon Sep 17 00:00:00 2001 From: Hazel6869 <1358508600@qq.com> Date: Thu, 13 Oct 2022 11:44:18 +0800 Subject: [PATCH 5/7] fix note --- conf/config-default.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/config-default.yaml b/conf/config-default.yaml index c2c5b3e72234..d50f7a1c9ff0 100755 --- a/conf/config-default.yaml +++ b/conf/config-default.yaml @@ -167,7 +167,7 @@ nginx_config: # config for render the template to generate n error_log: logs/error.log error_log_level: warn # warn,error worker_processes: auto # if you want use multiple cores in container, you can inject the number of cpu as environment variable "APISIX_WORKER_PROCESSES" - enable_cpu_affinity: false # enable cpu affinity, this is just work well only on physical machine + enable_cpu_affinity: false # disable CPU affinity by default, if APISIX is deployed on a physical machine, it can be enabled and work well. worker_rlimit_nofile: 20480 # the number of files a worker process can open, should be larger than worker_connections worker_shutdown_timeout: 240s # timeout for a graceful shutdown of worker processes From 57c1e5ee6183687d2faa6b3abb3bde693c7c57af Mon Sep 17 00:00:00 2001 From: chengxiaolan <30279880+Hazel6869@users.noreply.github.com> Date: Fri, 14 Oct 2022 17:09:50 +0800 Subject: [PATCH 6/7] Update t/cli/test_main.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 罗泽轩 --- t/cli/test_main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/cli/test_main.sh b/t/cli/test_main.sh index 8d6ab6d41413..71485bc74bb4 100755 --- a/t/cli/test_main.sh +++ b/t/cli/test_main.sh @@ -448,7 +448,7 @@ make init count=`grep -c "worker_cpu_affinity" conf/nginx.conf || true` if [ $count -ne 0 ]; then - echo "failed: nginx.conf file found worker_cpu_affinity when disable it" + echo "failed: nginx.conf file found worker_cpu_affinity when disabling it" exit 1 fi From 8a2a5d251992b9936f3c5bfe10f89caeed6eafdf Mon Sep 17 00:00:00 2001 From: chengxiaolan <30279880+Hazel6869@users.noreply.github.com> Date: Fri, 14 Oct 2022 17:09:59 +0800 Subject: [PATCH 7/7] Update t/cli/test_main.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 罗泽轩 --- t/cli/test_main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/cli/test_main.sh b/t/cli/test_main.sh index 71485bc74bb4..0b7a37bd7ff0 100755 --- a/t/cli/test_main.sh +++ b/t/cli/test_main.sh @@ -452,7 +452,7 @@ if [ $count -ne 0 ]; then exit 1 fi -echo "passed: nginx.conf file disable cpu affinity" +echo "passed: nginx.conf file disables cpu affinity" # check the 'worker_shutdown_timeout' in 'nginx.conf' .