-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
fix: validation during merging node_listen configuration #4881
Conversation
Signed-off-by: wayne-cheng <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a test in t/cli/test_validate_config.sh?
OK, Please retest. @spacewander |
Signed-off-by: wayne-cheng <[email protected]>
5aa13ae
to
8a69e06
Compare
|
||
echo ' | ||
apisix: | ||
node_listen: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we keep the table in conf/config-default.yaml and use number in config.yaml? Better to avoid touching config-default.yaml in the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous existing test cases which use number in config.yaml
have achieved this goal you said.
Take an example from the file t/cli/test_main.sh
:
echo "
apisix:
node_listen:
- 9080
- 9081
- 9082
ssl:
listen_port:
- 9443
- 9444
- 9445
" > conf/config.yaml
make init
This test that I added in t/cli/test_validate_config.sh
is used to test the case that the config-default.yaml
use number. In fact, the config-default.yaml
hasn’t changed because the test case exec git chekout conf/config-default.yaml
in the end.
What do you think? @spacewander
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.
apisix/cli/file.lua
Outdated
return true | ||
end | ||
|
||
if path == "apisix->ssl->listen" and type_val == "number" then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what apisix->ssl->listen
it is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tzssangglass The config apisix.ssl.listen
will be used in another PR (#4856). This will not affect the current code, do I remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think remove it is better and add it to the PRs that need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I have removed it, please retest. @tzssangglass
if (ppath == "nginx_config" or str_sub(ppath, 1, 14) == "nginx_config->") and | ||
(type_val == "number" or type_val == "string") | ||
then | ||
local path = ppath == "" and key or ppath .. "->" .. key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use JSON schema to check it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@membphis The old code has been the schema like ppath .. "->" .. key
,and it used to print log. If change this to JSON,many test cases could be affected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, got it. thx
Signed-off-by: wayne-cheng <[email protected]>
Signed-off-by: wayne-cheng [email protected]
This PR is used to solve a bug found in another PR (#4856).
When the conifg
apisix.node_liste
is set to a array in theconifg-default.yaml
, but the user'sconfig.yaml
use the type number,a error will occur.
More detail, Please see #4856 (comment)
PTAL @spacewander
You can use the existing test cases for testing, since the vaule type of the config
apisix.node_listen
in theconfig-default.yaml
is changed to the type array.Pre-submission checklist: