diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java b/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java index ba76c9ab7d2..46f3a6fb315 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java @@ -683,15 +683,10 @@ public class ZenDiscovery extends AbstractLifecycleComponent implements Discover return currentState; } - DiscoveryNodes discoveryNodes = DiscoveryNodes.builder(currentState.nodes()) - // make sure the old master node, which has failed, is not part of the nodes we publish - .remove(masterNode) - .masterNodeId(null).build(); - // flush any pending cluster states from old master, so it will not be set as master again publishClusterState.pendingStatesQueue().failAllStatesAndClear(new ElasticsearchException("master left [{}]", reason)); - return rejoin(ClusterState.builder(currentState).nodes(discoveryNodes).build(), "master left (reason = " + reason + ")"); + return rejoin(currentState, "master left (reason = " + reason + ")"); } @Override diff --git a/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java b/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java index 83472a1edc4..fd68e484062 100644 --- a/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java @@ -132,7 +132,9 @@ public class MinimumMasterNodesIT extends ESIntegTestCase { }); state = client().admin().cluster().prepareState().setLocal(true).execute().actionGet().getState(); assertThat(state.blocks().hasGlobalBlock(DiscoverySettings.NO_MASTER_BLOCK_ID), equalTo(true)); - assertThat(state.nodes().getSize(), equalTo(1)); // verify that we still see the local node in the cluster state + // verify that both nodes are still in the cluster state but there is no master + assertThat(state.nodes().getSize(), equalTo(2)); + assertThat(state.nodes().getMasterNode(), equalTo(null)); logger.info("--> starting the previous master node again..."); internalCluster().startNode(settings); diff --git a/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java b/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java index 5e40e529dae..2ea675ab3f7 100644 --- a/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java +++ b/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java @@ -993,7 +993,11 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { String isolatedNode = randomBoolean() ? masterNode : nonMasterNode; TwoPartitions partitions = isolateNode(isolatedNode); - NetworkDisruption networkDisruption = addRandomDisruptionType(partitions); + // we cannot use the NetworkUnresponsive disruption type here as it will swallow the "shard failed" request, calling neither + // onSuccess nor onFailure on the provided listener. + NetworkLinkDisruptionType disruptionType = new NetworkDisconnect(); + NetworkDisruption networkDisruption = new NetworkDisruption(partitions, disruptionType); + setDisruptionScheme(networkDisruption); networkDisruption.startDisrupting(); service.localShardFailed(failedShard, "simulated", new CorruptIndexException("simulated", (String) null), new