feat: add method that parse ip from /etc/hosts in high priority#8270
Conversation
|
Need test cases also. |
|
please approve running workflows @spacewander |
|
I analyze the error test cases reported by the CI, but I find that It has nothing to do with the code I commit, what I should do |
|
The tests fail because there is no "dns resolver domain: xxx to yyy" in the error.log, as resolving host in /etc/hosts doesn't go through the DNS client. Maybe you can add a similar log to let test pass. |
Thx, How can i trigger ci locally. I want to know the cause . |
You can submit the PR to your fork, where you have the right to rerun it if you want. |
|
I Find out that some test cases can't match this feature. So I modify some test-case code . Please review my thoughts @spacewander |
| -- use ipv4 in high priority | ||
| local ip = rev["ipv4"] | ||
| if not ip then | ||
| ip = rev["ipv6"] |
There was a problem hiding this comment.
We need to consider this setting:
apisix/conf/config-default.yaml
Line 35 in 2f4a4db
There was a problem hiding this comment.
I thought of this setting before, But I think when the default value of this setting is true , We also use ipv4 . So I think the ip's mapping that in /etc/hosts decides, but I improve ipv4's priority
There was a problem hiding this comment.
When the users disable ipv6, we should not return the IPv6 address in /etc/hosts to them.
| } | ||
| } | ||
| --- request | ||
| GET /t |
There was a problem hiding this comment.
We can set the common sections at the top of this file like
Line 23 in 2f4a4db
So we don't need to repeat it in each test.
| if not hosts then | ||
| return hosts, err | ||
| end | ||
| HOSTS_IP_MATCH_CACHE = hosts |
There was a problem hiding this comment.
When will HOSTS_IP_MATCH_CACHE be cleaned? APISIX will not update it after it is read at startup. Unless APISIX is restarted.
There was a problem hiding this comment.
This kind of configuration is basically unchanged, so I didn't consider reloading logic at that time
| -- use ipv4 in high priority | ||
| local ip = rev["ipv4"] | ||
| if not ip then | ||
| ip = rev["ipv6"] |
There was a problem hiding this comment.
When the users disable ipv6, we should not return the IPv6 address in /etc/hosts to them.
|
|
||
| if (!$block->request) { | ||
| $block->set_value("request", "GET /t"); | ||
| } |
There was a problem hiding this comment.
Let's enable the no_error_log by default too:
Line 34 in ae400b9
…fy test case and use ops enable_ipv6
Description
Fixes #5233
Checklist