Merge pull request #5481 from ElvinEfendi/fix-first-backend-sync

fix first backend sync
This commit is contained in:
Kubernetes Prow Robot 2020-04-30 19:10:05 -07:00 committed by GitHub
commit 1d4f16573b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -248,11 +248,18 @@ local function get_balancer()
end
function _M.init_worker()
sync_backends() -- when worker starts, sync backends without delay
local _, err = ngx.timer.every(BACKENDS_SYNC_INTERVAL, sync_backends)
if err then
ngx.log(ngx.ERR, "error when setting up timer.every for sync_backends: ",
tostring(err))
-- when worker starts, sync backends without delay
-- we call it in timer because for endpoints that require
-- DNS resolution it needs to use socket which is not avalable in
-- init_worker phase
local ok, err = ngx.timer.at(0, sync_backends)
if not ok then
ngx.log(ngx.ERR, "failed to create timer: ", err)
end
ok, err = ngx.timer.every(BACKENDS_SYNC_INTERVAL, sync_backends)
if not ok then
ngx.log(ngx.ERR, "error when setting up timer.every for sync_backends: ", err)
end
end