-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix: can not get hostname in redhat #12267
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
Changes from 4 commits
f2287a3
7ea0897
c42db6f
7c07f93
c7d1f6d
2c4c444
ac6504b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -393,3 +393,43 @@ res:nil | |
| res:5 | ||
| res:12 | ||
| res:7 | ||
|
|
||
|
|
||
|
|
||
| === TEST 13: gethostname | ||
| --- config | ||
| location /t { | ||
| content_by_lua_block { | ||
| local core = require("apisix.core") | ||
| local hostname = core.utils.gethostname() | ||
bzp2010 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ngx.say("hostname: ", hostname) | ||
| local hostname2 = core.utils.gethostname() | ||
| ngx.say("hostname cached: ", hostname == hostname2) | ||
| ngx.say("hostname valid: ", hostname ~= "" and (hostname ~= "unknown" or true)) | ||
|
||
|
|
||
| local handle = io.popen("/bin/hostname") | ||
| if handle then | ||
| local system_hostname = handle:read("*a") | ||
| handle:close() | ||
| if system_hostname then | ||
| system_hostname = string.gsub(system_hostname, "\n$", "") | ||
| ngx.say("system hostname: ", system_hostname) | ||
| ngx.say("hostname match: ", hostname == system_hostname) | ||
| else | ||
| ngx.say("system hostname: failed to read") | ||
| ngx.say("hostname match: unable to verify") | ||
| end | ||
| else | ||
| ngx.say("system hostname: failed to execute /bin/hostname") | ||
| ngx.say("hostname match: unable to verify") | ||
| end | ||
| } | ||
| } | ||
| --- request | ||
| GET /t | ||
| --- response_body_like | ||
| hostname: .+ | ||
| hostname cached: true | ||
| hostname valid: true | ||
| system hostname: .+ | ||
| hostname match: true | ||
Uh oh!
There was an error while loading. Please reload this page.