Skip to content

Commit 1e71a7e

Browse files
committed
UnicastHostsProvider should use version.minimumCompatibilityVersion()
The UnicastHostsProvider implementation creates DiscoveryNodes that are used as an initial seed for unicast based discovery. At the moment it uses Version.CURRENT for those DiscoveryNode object, which confuses the backwards compatibility layer to think this nodes are of the latest version. This causes new nodes to fail to join old nodes as the ping serialization goes wrong. Instead we should use version.minimumCompatibilityVersion(). Closes #47. (cherry picked from commit 188179f)
1 parent 300320f commit 1e71a7e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/main/java/org/elasticsearch/discovery/azure/AzureDiscovery.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.elasticsearch.discovery.azure;
2121

22+
import org.elasticsearch.Version;
2223
import org.elasticsearch.cloud.azure.AzureComputeService;
2324
import org.elasticsearch.cluster.ClusterName;
2425
import org.elasticsearch.cluster.ClusterService;
@@ -49,7 +50,8 @@ public class AzureDiscovery extends ZenDiscovery {
4950
public AzureDiscovery(Settings settings, ClusterName clusterName, ThreadPool threadPool, TransportService transportService,
5051
ClusterService clusterService, NodeSettingsService nodeSettingsService, ZenPingService pingService,
5152
DiscoveryNodeService discoveryNodeService, AzureComputeService azureService, NetworkService networkService,
52-
DiscoverySettings discoverySettings, ElectMasterService electMasterService, DynamicSettings dynamicSettings) {
53+
DiscoverySettings discoverySettings, ElectMasterService electMasterService, DynamicSettings dynamicSettings,
54+
Version version) {
5355
super(settings, clusterName, threadPool, transportService, clusterService, nodeSettingsService,
5456
discoveryNodeService, pingService, electMasterService, discoverySettings, dynamicSettings);
5557
if (settings.getAsBoolean("cloud.enabled", true)) {
@@ -65,7 +67,7 @@ public AzureDiscovery(Settings settings, ClusterName clusterName, ThreadPool thr
6567
if (unicastZenPing != null) {
6668
// update the unicast zen ping to add cloud hosts provider
6769
// and, while we are at it, use only it and not the multicast for example
68-
unicastZenPing.addHostsProvider(new AzureUnicastHostsProvider(settings, azureService, transportService, networkService));
70+
unicastZenPing.addHostsProvider(new AzureUnicastHostsProvider(settings, azureService, transportService, networkService, version));
6971
pingService.zenPings(ImmutableList.of(unicastZenPing));
7072
} else {
7173
logger.warn("failed to apply azure unicast discovery, no unicast ping found");

src/main/java/org/elasticsearch/discovery/azure/AzureUnicastHostsProvider.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public static enum HostType {
5353
private final AzureComputeService azureComputeService;
5454
private TransportService transportService;
5555
private NetworkService networkService;
56+
private final Version version;
5657

5758
private final TimeValue refreshInterval;
5859
private long lastRefresh;
@@ -62,11 +63,13 @@ public static enum HostType {
6263
@Inject
6364
public AzureUnicastHostsProvider(Settings settings, AzureComputeService azureComputeService,
6465
TransportService transportService,
65-
NetworkService networkService) {
66+
NetworkService networkService,
67+
Version version) {
6668
super(settings);
6769
this.azureComputeService = azureComputeService;
6870
this.transportService = transportService;
6971
this.networkService = networkService;
72+
this.version = version;
7073

7174
this.refreshInterval = componentSettings.getAsTime(AzureComputeService.Fields.REFRESH,
7275
settings.getAsTime("cloud.azure." + AzureComputeService.Fields.REFRESH, TimeValue.timeValueSeconds(0)));
@@ -139,7 +142,7 @@ public List<DiscoveryNode> buildDynamicNodes() {
139142
TransportAddress[] addresses = transportService.addressesFromString(networkAddress);
140143
// we only limit to 1 addresses, makes no sense to ping 100 ports
141144
logger.trace("adding {}, transport_address {}", networkAddress, addresses[0]);
142-
cachedDiscoNodes.add(new DiscoveryNode("#cloud-" + instance.getName(), addresses[0], Version.CURRENT));
145+
cachedDiscoNodes.add(new DiscoveryNode("#cloud-" + instance.getName(), addresses[0], version.minimumCompatibilityVersion()));
143146
}
144147

145148
}

0 commit comments

Comments
 (0)