From 30dc244820cc93d58d64afc8fdbad4648d365ad8 Mon Sep 17 00:00:00 2001 From: Wangchong Zhou Date: Thu, 31 Oct 2019 13:00:34 -0700 Subject: [PATCH] fix(healthcheck) fail hard when initial locking_target_list failed Since we didn't protect nil ptr of `targets` in other places in this library, error on `locking_target_list` which makes `targets` remain `nil` should be considered unrecoverable failure. See also https://github.com/Kong/kong/issues/5189 --- lib/resty/healthcheck.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/resty/healthcheck.lua b/lib/resty/healthcheck.lua index c87eb9a9..264e047d 100644 --- a/lib/resty/healthcheck.lua +++ b/lib/resty/healthcheck.lua @@ -1324,7 +1324,9 @@ function _M.new(opts) return true end) if not ok then - self:log(ERR, "Error loading initial target list: ", err) + -- locking failed, we don't protect `targets` of being nil in other places + -- so consider this as not recoverable + return nil, "Error loading initial target list: " .. err end self.ev_callback = function(data, event)