fix(emqx_conf_app): fix release version detect during cluster conf sync

This commit is contained in:
Zaiming (Stone) Shi 2023-06-21 09:17:34 +02:00
parent dddccfdc5c
commit 045ed340dd
1 changed files with 14 additions and 11 deletions

View File

@ -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) ->