diff --git a/apps/emqx_conf/src/emqx_conf_app.erl b/apps/emqx_conf/src/emqx_conf_app.erl index 1505b8c3e..f5ecbedb6 100644 --- a/apps/emqx_conf/src/emqx_conf_app.erl +++ b/apps/emqx_conf/src/emqx_conf_app.erl @@ -180,17 +180,7 @@ sync_cluster_conf2(Nodes) -> %% @private Filter out the nodes which are running a newer version than this node. sync_cluster_conf3(Ready) -> - NotNewer = fun({ok, #{release := RemoteRelease}}) -> - try - emqx_release:vsn_compare(RemoteRelease) =/= newer - catch - _:_ -> - %% If the version is not valid (without v or e prefix), - %% we know it's older than v5.1.0/e5.1.0 - true - end - end, - case lists:filter(NotNewer, Ready) of + case lists:filter(fun is_older_or_same_version/1, Ready) of [] -> %% All available core nodes are running a newer version than this node. %% Start this node without syncing cluster config from them. @@ -213,6 +203,19 @@ sync_cluster_conf3(Ready) -> sync_cluster_conf4(Ready2) end. +is_older_or_same_version({ok, #{release := RemoteRelease}}) -> + try + emqx_release:vsn_compare(RemoteRelease) =/= newer + catch + _:_ -> + %% If the version is not valid (without v or e prefix), + %% we know it's older than v5.1.0/e5.1.0 + true + end; +is_older_or_same_version(_) -> + %% older version has no 'release' field + true. + %% @private Some core nodes are running and replied with their configs successfully. %% Try to sort the results and save the first one for local use. sync_cluster_conf4(Ready) ->