From f102499aecc8a6dd4d008d025669543568fab990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chrz=C4=85szcz?= Date: Tue, 9 Apr 2024 09:29:40 +0200 Subject: [PATCH] Put CETS version in cluster name When performing a rolling upgrade e.g. from 6.2.0 to the upcoming 6.2.1, CETS would crash on all nodes due to version incompatibility. This can be prevented by putting cets 'Major.Minor' version in the cluster name, making the two cluster components disjoint during upgrade. The only thing to keep in mind is to bump the Major or Minor version number when there is any incompatibility in the CETS inter-node API. --- src/mongoose_cets_discovery_rdbms.erl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/mongoose_cets_discovery_rdbms.erl b/src/mongoose_cets_discovery_rdbms.erl index 3e0042e81db..b6342bd0741 100644 --- a/src/mongoose_cets_discovery_rdbms.erl +++ b/src/mongoose_cets_discovery_rdbms.erl @@ -25,8 +25,14 @@ -spec init(opts()) -> state(). init(Opts = #{cluster_name := ClusterName, node_name_to_insert := Node}) when is_binary(ClusterName), is_binary(Node) -> - Keys = [cluster_name, node_name_to_insert, last_query_info, expire_time, node_ip_binary], - maps:with(Keys, maps:merge(defaults(), Opts)). + Keys = [node_name_to_insert, expire_time, last_query_info, node_ip_binary], + StateOpts = maps:merge(defaults(), maps:with(Keys, Opts)), + StateOpts#{cluster_name => cluster_name_with_vsn(ClusterName)}. + +cluster_name_with_vsn(ClusterName) -> + {ok, CetsVsn} = application:get_key(cets, vsn), + [MajorVsn, MinorVsn | _] = string:tokens(CetsVsn, "."), + iolist_to_binary([ClusterName, $-, MajorVsn, $., MinorVsn]). defaults() -> #{expire_time => 60 * 60 * 1, %% 1 hour in seconds