diff --git a/server/src/main/java/org/elasticsearch/cluster/coordination/ClusterFormationFailureHelper.java b/server/src/main/java/org/elasticsearch/cluster/coordination/ClusterFormationFailureHelper.java index 017231c179a..a4f31fb3ab1 100644 --- a/server/src/main/java/org/elasticsearch/cluster/coordination/ClusterFormationFailureHelper.java +++ b/server/src/main/java/org/elasticsearch/cluster/coordination/ClusterFormationFailureHelper.java @@ -141,7 +141,7 @@ public class ClusterFormationFailureHelper { final String discoveryWillContinueDescription = String.format(Locale.ROOT, "discovery will continue using %s from hosts providers and %s from last-known cluster state; " + "node term %d, last-accepted version %d in term %d", - resolvedAddresses, clusterStateNodes, currentTerm, clusterState.version(), clusterState.term()); + resolvedAddresses, clusterStateNodes, currentTerm, clusterState.getVersionOrMetaDataVersion(), clusterState.term()); final String discoveryStateIgnoringQuorum = String.format(Locale.ROOT, "have discovered %s; %s", foundPeers, discoveryWillContinueDescription); @@ -191,7 +191,8 @@ public class ClusterFormationFailureHelper { foundPeers.forEach(voteCollection::addVote); final String isQuorumOrNot = electionStrategy.isElectionQuorum(clusterState.nodes().getLocalNode(), currentTerm, clusterState.term(), - clusterState.version(), clusterState.getLastCommittedConfiguration(), clusterState.getLastAcceptedConfiguration(), + clusterState.getVersionOrMetaDataVersion(), clusterState.getLastCommittedConfiguration(), + clusterState.getLastAcceptedConfiguration(), voteCollection) ? "is a quorum" : "is not a quorum"; return String.format(Locale.ROOT, diff --git a/server/src/test/java/org/elasticsearch/cluster/coordination/ClusterFormationFailureHelperTests.java b/server/src/test/java/org/elasticsearch/cluster/coordination/ClusterFormationFailureHelperTests.java index 05f12ac72b2..ec115265652 100644 --- a/server/src/test/java/org/elasticsearch/cluster/coordination/ClusterFormationFailureHelperTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/coordination/ClusterFormationFailureHelperTests.java @@ -142,24 +142,41 @@ public class ClusterFormationFailureHelperTests extends ESTestCase { public void testDescriptionOnMasterIneligibleNodes() { final DiscoveryNode localNode = new DiscoveryNode("local", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT); final ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT) - .version(12L).nodes(DiscoveryNodes.builder().add(localNode).localNodeId(localNode.getId())).build(); + .version(12L) + .metaData(MetaData.builder().coordinationMetaData(CoordinationMetaData.builder().term(4L).build())) + .nodes(DiscoveryNodes.builder().add(localNode).localNodeId(localNode.getId())).build(); assertThat(new ClusterFormationState(Settings.EMPTY, clusterState, emptyList(), emptyList(), 15L, electionStrategy) .getDescription(), is("master not discovered yet: have discovered []; discovery will continue using [] from hosts providers " + - "and [] from last-known cluster state; node term 15, last-accepted version 12 in term 0")); + "and [] from last-known cluster state; node term 15, last-accepted version 12 in term 4")); final TransportAddress otherAddress = buildNewFakeTransportAddress(); assertThat(new ClusterFormationState(Settings.EMPTY, clusterState, singletonList(otherAddress), emptyList(), 16L, electionStrategy) .getDescription(), is("master not discovered yet: have discovered []; discovery will continue using [" + otherAddress + - "] from hosts providers and [] from last-known cluster state; node term 16, last-accepted version 12 in term 0")); + "] from hosts providers and [] from last-known cluster state; node term 16, last-accepted version 12 in term 4")); final DiscoveryNode otherNode = new DiscoveryNode("other", buildNewFakeTransportAddress(), Version.CURRENT); assertThat(new ClusterFormationState(Settings.EMPTY, clusterState, emptyList(), singletonList(otherNode), 17L, electionStrategy) .getDescription(), is("master not discovered yet: have discovered [" + otherNode + "]; discovery will continue using [] from hosts providers " + - "and [] from last-known cluster state; node term 17, last-accepted version 12 in term 0")); + "and [] from last-known cluster state; node term 17, last-accepted version 12 in term 4")); + } + + public void testDescriptionForBWCState() { + final DiscoveryNode localNode = new DiscoveryNode("local", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT); + final ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT) + .metaData(MetaData.builder() + .version(42L) // check that we use metadata version in case of BWC term 0 + .coordinationMetaData(CoordinationMetaData.builder().term(Coordinator.ZEN1_BWC_TERM).build()) + .build()) + .nodes(DiscoveryNodes.builder().add(localNode).localNodeId(localNode.getId())).build(); + + assertThat(new ClusterFormationState(Settings.EMPTY, clusterState, emptyList(), emptyList(), 15L, electionStrategy) + .getDescription(), + is("master not discovered yet: have discovered []; discovery will continue using [] from hosts providers " + + "and [] from last-known cluster state; node term 15, last-accepted version 42 in term 0")); } public void testDescriptionBeforeBootstrapping() {