apisix icon indicating copy to clipboard operation
apisix copied to clipboard

bug: when modify config file apisix shoud check config file

Open Infra-YH opened this issue 5 years ago • 12 comments

Issue description

Environment

  • apisix version (cmd: apisix version): apisix 2.1
  • OS: (cmd: uname -a) centos 7.6
  • OpenResty / Nginx version: (cmd: nginx -V or openresty -V)

Minimal test code / Steps to reproduce the issue

  1. when apisix running and modify config file ,when config file error apisix restart fail ,service down
  2. apisix should check modify config file , example nginx -t , avoid error 3.

What's the actual result? (including assertion message & call stack if applicable)

What's the expected result?

Infra-YH avatar Jan 09 '21 03:01 Infra-YH

Thank you very much for your report, we need to determine this issue. It would be better if you could provide a recurring use case of a problem.

Firstsawyou avatar Jan 09 '21 03:01 Firstsawyou

if apisix config file errory when apisix restart or apisix reload appear error
example: when modify config file apper errory so easy config file yaml format error

It is strongly recommended to add configuration file verification to restart or reload the configuration file

better with cli example apisix check config ,return configuration file is ok, aviod restart fail

Infra-YH avatar Jan 09 '21 04:01 Infra-YH

example: cat /usr/local/apisix/conf/config.yaml | tail -3 # the default value is true, e.g. the certificate will be verified strictly.

test file error

123 apisix restart lua: /usr/local/apisix/deps/share/lua/5.1/tinyyaml.lua:641: failed to classify line: 123 stack traceback: [C]: in function 'error' /usr/local/apisix/deps/share/lua/5.1/tinyyaml.lua:641: in function 'parsemap' /usr/local/apisix/deps/share/lua/5.1/tinyyaml.lua:735: in function 'parsedocuments' /usr/local/apisix/deps/share/lua/5.1/tinyyaml.lua:760: in function 'parse' /usr/share/lua/5.1/apisix/cli/file.lua:132: in function 'read_yaml_conf' /usr/bin/apisix:156: in function 'init' /usr/bin/apisix:363: in function 'start' /usr/bin/apisix:377: in function '?' /usr/bin/apisix:418: in main chunk [C]: ? aviod apisix restart fali, service fail

Infra-YH avatar Jan 09 '21 04:01 Infra-YH

Yes, the output is no so friendly. @Yangzcy423911 Would you like to submit a PR to optimize the interaction when configuration file is malformed, thanks!

tokers avatar Jan 09 '21 05:01 tokers

welcome PR to fix this issue

membphis avatar Jan 11 '21 12:01 membphis

shouldn't test usage added to apisix help? as of 2.12.1 it's not there

apit avatar May 26 '22 02:05 apit

shouldn't test usage added to apisix help? as of 2.12.1 it's not there

test usage has been released as of 2.11.0. If this is not your verification result, you can submit a new issue.

tzssangglass avatar May 26 '22 05:05 tzssangglass

i mean, i didn't know it exists:

/opt/apisix> docker-compose exec apisix apisix help
/usr/local/openresty/luajit/bin/luajit ./apisix/cli/apisix.lua help
Usage: apisix [action] <argument>

help:       show this message, then exit
init:       initialize the local nginx.conf
init_etcd:  initialize the data of etcd
start:      start the apisix server
stop:       stop the apisix server
quit:       stop the apisix server gracefully
restart:    restart the apisix server
reload:     reload the apisix server
version:    print the version of apisix

apit avatar May 26 '22 09:05 apit

i mean, i didn't know it exists:

maybe we need to add test to apisix help? cc @spacewander @nic-chen

tzssangglass avatar May 26 '22 14:05 tzssangglass

i mean, i didn't know it exists:

maybe we need to add test to apisix help? cc @spacewander @nic-chen

It's usefult. Just like nginx -t.

tokers avatar May 27 '22 00:05 tokers

i mean, i didn't know it exists:

maybe we need to add test to apisix help? cc @spacewander @nic-chen

+1 add apisix test to apisix help, people could know this command quickly.

@apit welcome to submit a PR to make it done. : )

nic-chen avatar May 27 '22 00:05 nic-chen

Let's move the discussion to https://github.com/apache/apisix/issues/7148 as this validation is already done.

spacewander avatar May 27 '22 01:05 spacewander