You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/12/31 06:38:55 UTC
[GitHub] [apisix] membphis opened a new issue #3169: chore: cache the error message when create new `healthcheck` instance
membphis opened a new issue #3169:
URL: https://github.com/apache/apisix/issues/3169
`healthcheck.new` may fail, we need to check the return value first.
https://github.com/apache/apisix/blob/4d316bc0681c80435ab1a3fc113c3c6ea3c82831/apisix/balancer.lua#L90
here is the doc:
![image](https://user-images.githubusercontent.com/6814606/103398025-c5663a00-4b75-11eb-8b5d-a7d9c202ee5d.png)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] membphis closed issue #3169: chore: cache the error message when create new `healthcheck` instance
Posted by GitBox <gi...@apache.org>.
membphis closed issue #3169:
URL: https://github.com/apache/apisix/issues/3169
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] membphis commented on issue #3169: chore: cache the error message when create new `healthcheck` instance
Posted by GitBox <gi...@apache.org>.
membphis commented on issue #3169:
URL: https://github.com/apache/apisix/issues/3169#issuecomment-752865195
The patch, it maybe useful for you. welcome PR ^_^
```patch
diff --git a/apisix/balancer.lua b/apisix/balancer.lua
index d80cb676..c644bdc3 100644
--- a/apisix/balancer.lua
+++ b/apisix/balancer.lua
@@ -87,11 +87,15 @@ local function create_checker(upstream, healthcheck_parent)
if healthcheck == nil then
healthcheck = require("resty.healthcheck")
end
- local checker = healthcheck.new({
+ local checker, err = healthcheck.new({
name = "upstream#" .. healthcheck_parent.key,
shm_name = "upstream-healthcheck",
checks = upstream.checks,
})
+ if not checker then
+ core.log.error("fail to create healthcheck instance: ", err)
+ return
+ end
local host = upstream.checks and upstream.checks.active and upstream.checks.active.host
local port = upstream.checks and upstream.checks.active and upstream.checks.active.port
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org