ChuanFF commented on code in PR #12991: URL: https://github.com/apache/apisix/pull/12991#discussion_r2866919283
########## apisix/balancer.lua: ########## @@ -178,6 +197,35 @@ local function set_balancer_opts(route, ctx) end +local function get_version_with_warm_up(version, up_conf) + if not up_conf.warm_up_conf or up_conf.warm_up_conf.finish then + return version + end + local warm_up_conf = up_conf.warm_up_conf + local warm_up_end_time = warm_up_conf.warm_up_end_time + if not warm_up_end_time then + local max_update_time = 0 + for _, node in ipairs(up_conf.nodes) do + if node.update_time and node.update_time > max_update_time then + max_update_time = node.update_time + end + end + if max_update_time > 0 then + warm_up_end_time = max_update_time + warm_up_conf.slow_start_time_seconds + warm_up_conf.warm_up_end_time = warm_up_end_time + end + end + + if warm_up_end_time and ngx_time() < warm_up_end_time then + version = version .. math_floor(ngx_time() / warm_up_conf.interval) + else + warm_up_conf.finish = true + end Review Comment: This code will not cause Lua coroutines to yield, and will not cause race conditions. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
