Skip to content

Commit

Permalink
Merge pull request #17665 from siyuanfoundation/3.4-downgrade
Browse files Browse the repository at this point in the history
[3.4] Allow new server to join higher cluster version if NextClusterVersionCompatible is true
  • Loading branch information
ahrtr authored Mar 29, 2024
2 parents 51f9d44 + 723ef9f commit 75f799c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion etcdmain/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ Clustering:
--enable-v2 '` + strconv.FormatBool(embed.DefaultEnableV2) + `'
Accept etcd V2 client requests.
--next-cluster-version-compatible 'false'
Enable 3.4 to be compatible with next version 3.5, to allow 3.4 server to join 3.5 cluster and start on 3.5 schema.
Enable 3.4 to be compatible with next version 3.5, to allow 3.4 server to join 3.5 cluster and start on 3.5 schema.
Security:
--cert-file ''
Expand Down
5 changes: 4 additions & 1 deletion etcdserver/cluster_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,17 @@ func decideClusterVersion(lg *zap.Logger, vers map[string]*version.Versions) *se
// cluster version in the range of [MinClusterVersion, Version] and no known members has a cluster version
// out of the range.
// We set this rule since when the local member joins, another member might be offline.
func isCompatibleWithCluster(lg *zap.Logger, cl *membership.RaftCluster, local types.ID, rt http.RoundTripper) bool {
func isCompatibleWithCluster(lg *zap.Logger, cl *membership.RaftCluster, local types.ID, rt http.RoundTripper, nextClusterVersionCompatible bool) bool {
vers := getVersions(lg, cl, local, rt)
minV := semver.Must(semver.NewVersion(version.MinClusterVersion))
maxV := semver.Must(semver.NewVersion(version.Version))
maxV = &semver.Version{
Major: maxV.Major,
Minor: maxV.Minor,
}
if nextClusterVersionCompatible {
maxV.Minor += 1
}
return isCompatibleWithVers(lg, vers, local, minV, maxV)
}

Expand Down
2 changes: 1 addition & 1 deletion etcdserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ func NewServer(cfg ServerConfig) (srv *EtcdServer, err error) {
if err = membership.ValidateClusterAndAssignIDs(cfg.Logger, cl, existingCluster); err != nil {
return nil, fmt.Errorf("error validating peerURLs %s: %v", existingCluster, err)
}
if !isCompatibleWithCluster(cfg.Logger, cl, cl.MemberByName(cfg.Name).ID, prt) {
if !isCompatibleWithCluster(cfg.Logger, cl, cl.MemberByName(cfg.Name).ID, prt, cfg.NextClusterVersionCompatible) {
return nil, fmt.Errorf("incompatible with current running cluster")
}

Expand Down

0 comments on commit 75f799c

Please sign in to comment.