Skip to content

Commit c652b58

Browse files
jmorph99bleskes
authored andcommitted
Remove discovery.type BWC layer from the EC2/Azure/GCE plugins #25080
Those plugins don't replace the discovery logic but rather only provide a custom unicast host provider for their respective platforms. in 5.1 we introduced the `discovery.zen.hosts_provider` setting to better reflect it. This PR removes BWC code in those plugins as it is not needed anymore Fixes #24543
1 parent a5658c0 commit c652b58

File tree

6 files changed

+10
-97
lines changed

6 files changed

+10
-97
lines changed

plugins/discovery-azure-classic/src/main/java/org/elasticsearch/plugin/discovery/azure/classic/AzureDiscoveryPlugin.java

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,15 @@
2222
import org.apache.logging.log4j.Logger;
2323
import org.elasticsearch.cloud.azure.classic.management.AzureComputeService;
2424
import org.elasticsearch.cloud.azure.classic.management.AzureComputeServiceImpl;
25-
import org.elasticsearch.cluster.routing.allocation.AllocationService;
26-
import org.elasticsearch.cluster.service.ClusterApplier;
27-
import org.elasticsearch.cluster.service.MasterService;
28-
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
2925
import org.elasticsearch.common.logging.DeprecationLogger;
3026
import org.elasticsearch.common.logging.Loggers;
3127
import org.elasticsearch.common.network.NetworkService;
32-
import org.elasticsearch.common.settings.ClusterSettings;
3328
import org.elasticsearch.common.settings.Setting;
3429
import org.elasticsearch.common.settings.Settings;
35-
import org.elasticsearch.discovery.Discovery;
36-
import org.elasticsearch.discovery.DiscoveryModule;
3730
import org.elasticsearch.discovery.azure.classic.AzureUnicastHostsProvider;
3831
import org.elasticsearch.discovery.zen.UnicastHostsProvider;
39-
import org.elasticsearch.discovery.zen.ZenDiscovery;
4032
import org.elasticsearch.plugins.DiscoveryPlugin;
4133
import org.elasticsearch.plugins.Plugin;
42-
import org.elasticsearch.threadpool.ThreadPool;
4334
import org.elasticsearch.transport.TransportService;
4435

4536
import java.util.Arrays;
@@ -73,17 +64,7 @@ public Map<String, Supplier<UnicastHostsProvider>> getZenHostsProviders(Transpor
7364
() -> new AzureUnicastHostsProvider(settings, createComputeService(), transportService, networkService));
7465
}
7566

76-
@Override
77-
public Map<String, Supplier<Discovery>> getDiscoveryTypes(ThreadPool threadPool, TransportService transportService,
78-
NamedWriteableRegistry namedWriteableRegistry,
79-
MasterService masterService, ClusterApplier clusterApplier,
80-
ClusterSettings clusterSettings, UnicastHostsProvider hostsProvider,
81-
AllocationService allocationService) {
82-
// this is for backcompat with pre 5.1, where users would set discovery.type to use ec2 hosts provider
83-
return Collections.singletonMap(AZURE, () ->
84-
new ZenDiscovery(settings, threadPool, transportService, namedWriteableRegistry, masterService, clusterApplier,
85-
clusterSettings, hostsProvider, allocationService));
86-
}
67+
8768

8869
@Override
8970
public List<Setting<?>> getSettings() {
@@ -99,19 +80,5 @@ public List<Setting<?>> getSettings() {
9980
AzureComputeService.Discovery.ENDPOINT_NAME_SETTING);
10081
}
10182

102-
@Override
103-
public Settings additionalSettings() {
104-
// For 5.0, the hosts provider was "zen", but this was before the discovery.zen.hosts_provider
105-
// setting existed. This check looks for the legacy setting, and sets hosts provider if set
106-
String discoveryType = DiscoveryModule.DISCOVERY_TYPE_SETTING.get(settings);
107-
if (discoveryType.equals(AZURE)) {
108-
deprecationLogger.deprecated("using [" + DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey() +
109-
"] to set hosts provider is deprecated; " +
110-
"set \"" + DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING.getKey() + ": " + AZURE + "\" instead");
111-
if (DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING.exists(settings) == false) {
112-
return Settings.builder().put(DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING.getKey(), AZURE).build();
113-
}
114-
}
115-
return Settings.EMPTY;
116-
}
83+
11784
}

plugins/discovery-azure-classic/src/test/java/org/elasticsearch/cloud/azure/classic/AbstractAzureComputeServiceTestCase.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import org.elasticsearch.cloud.azure.classic.management.AzureComputeService.Discovery;
2424
import org.elasticsearch.cloud.azure.classic.management.AzureComputeService.Management;
2525
import org.elasticsearch.common.settings.Settings;
26-
import org.elasticsearch.node.Node;
27-
import org.elasticsearch.plugin.discovery.azure.classic.AzureDiscoveryPlugin;
2826
import org.elasticsearch.plugins.Plugin;
2927
import org.elasticsearch.test.ESIntegTestCase;
3028

@@ -44,7 +42,7 @@ public AbstractAzureComputeServiceTestCase(Class<? extends Plugin> mockPlugin) {
4442
protected Settings nodeSettings(int nodeOrdinal) {
4543
Settings.Builder builder = Settings.builder()
4644
.put(super.nodeSettings(nodeOrdinal))
47-
.put("discovery.type", "azure");
45+
.put("discovery.zen.hosts_provider", "azure");
4846

4947
// We add a fake subscription_id to start mock compute service
5048
builder.put(Management.SUBSCRIPTION_ID_SETTING.getKey(), "fake")

plugins/discovery-azure-classic/src/test/java/org/elasticsearch/discovery/azure/classic/AzureDiscoveryClusterFormationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ protected Settings nodeSettings(int nodeOrdinal) {
106106
throw new RuntimeException(e);
107107
}
108108
return Settings.builder().put(super.nodeSettings(nodeOrdinal))
109-
.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), AzureDiscoveryPlugin.AZURE)
109+
.put(DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING.getKey(), AzureDiscoveryPlugin.AZURE)
110110
.put(Environment.PATH_LOGS_SETTING.getKey(), resolve)
111111
.put(TransportSettings.PORT.getKey(), 0)
112112
.put(Node.WRITE_PORTS_FILE_SETTING.getKey(), "true")

plugins/discovery-ec2/src/main/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryPlugin.java

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,24 @@
2424
import org.apache.lucene.util.IOUtils;
2525
import org.apache.lucene.util.SetOnce;
2626
import org.elasticsearch.SpecialPermission;
27-
import org.elasticsearch.cluster.routing.allocation.AllocationService;
28-
import org.elasticsearch.cluster.service.ClusterApplier;
2927
import org.elasticsearch.common.SuppressForbidden;
30-
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
3128
import org.elasticsearch.common.logging.DeprecationLogger;
3229
import org.elasticsearch.common.logging.Loggers;
3330
import org.elasticsearch.common.network.NetworkService;
34-
import org.elasticsearch.common.settings.ClusterSettings;
3531
import org.elasticsearch.common.settings.Setting;
3632
import org.elasticsearch.common.settings.Settings;
37-
import org.elasticsearch.discovery.Discovery;
38-
import org.elasticsearch.discovery.DiscoveryModule;
39-
import org.elasticsearch.cluster.service.MasterService;
4033
import org.elasticsearch.discovery.zen.UnicastHostsProvider;
41-
import org.elasticsearch.discovery.zen.ZenDiscovery;
4234
import org.elasticsearch.node.Node;
4335
import org.elasticsearch.plugins.DiscoveryPlugin;
4436
import org.elasticsearch.plugins.Plugin;
45-
import org.elasticsearch.threadpool.ThreadPool;
4637
import org.elasticsearch.transport.TransportService;
4738

39+
import java.io.UncheckedIOException;
4840
import java.io.BufferedReader;
49-
import java.io.Closeable;
5041
import java.io.IOException;
5142
import java.io.InputStream;
5243
import java.io.InputStreamReader;
53-
import java.io.UncheckedIOException;
44+
import java.io.Closeable;
5445
import java.net.URL;
5546
import java.net.URLConnection;
5647
import java.nio.charset.StandardCharsets;
@@ -95,17 +86,7 @@ public Ec2DiscoveryPlugin(Settings settings) {
9586
this.settings = settings;
9687
}
9788

98-
@Override
99-
public Map<String, Supplier<Discovery>> getDiscoveryTypes(ThreadPool threadPool, TransportService transportService,
100-
NamedWriteableRegistry namedWriteableRegistry,
101-
MasterService masterService, ClusterApplier clusterApplier,
102-
ClusterSettings clusterSettings, UnicastHostsProvider hostsProvider,
103-
AllocationService allocationService) {
104-
// this is for backcompat with pre 5.1, where users would set discovery.type to use ec2 hosts provider
105-
return Collections.singletonMap(EC2, () ->
106-
new ZenDiscovery(settings, threadPool, transportService, namedWriteableRegistry, masterService, clusterApplier,
107-
clusterSettings, hostsProvider, allocationService));
108-
}
89+
10990

11091
@Override
11192
public NetworkService.CustomNameResolver getCustomNameResolver(Settings settings) {

plugins/discovery-gce/src/main/java/org/elasticsearch/plugin/discovery/gce/GceDiscoveryPlugin.java

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,15 @@
2929
import org.elasticsearch.cloud.gce.GceMetadataService;
3030
import org.elasticsearch.cloud.gce.network.GceNameResolver;
3131
import org.elasticsearch.cloud.gce.util.Access;
32-
import org.elasticsearch.cluster.routing.allocation.AllocationService;
33-
import org.elasticsearch.cluster.service.ClusterApplier;
34-
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
3532
import org.elasticsearch.common.logging.DeprecationLogger;
3633
import org.elasticsearch.common.logging.Loggers;
3734
import org.elasticsearch.common.network.NetworkService;
38-
import org.elasticsearch.common.settings.ClusterSettings;
3935
import org.elasticsearch.common.settings.Setting;
4036
import org.elasticsearch.common.settings.Settings;
41-
import org.elasticsearch.discovery.Discovery;
42-
import org.elasticsearch.discovery.DiscoveryModule;
43-
import org.elasticsearch.cluster.service.MasterService;
4437
import org.elasticsearch.discovery.gce.GceUnicastHostsProvider;
4538
import org.elasticsearch.discovery.zen.UnicastHostsProvider;
46-
import org.elasticsearch.discovery.zen.ZenDiscovery;
4739
import org.elasticsearch.plugins.DiscoveryPlugin;
4840
import org.elasticsearch.plugins.Plugin;
49-
import org.elasticsearch.threadpool.ThreadPool;
5041
import org.elasticsearch.transport.TransportService;
5142

5243
import java.io.Closeable;
@@ -83,17 +74,7 @@ public GceDiscoveryPlugin(Settings settings) {
8374
logger.trace("starting gce discovery plugin...");
8475
}
8576

86-
@Override
87-
public Map<String, Supplier<Discovery>> getDiscoveryTypes(ThreadPool threadPool, TransportService transportService,
88-
NamedWriteableRegistry namedWriteableRegistry,
89-
MasterService masterService, ClusterApplier clusterApplier,
90-
ClusterSettings clusterSettings, UnicastHostsProvider hostsProvider,
91-
AllocationService allocationService) {
92-
// this is for backcompat with pre 5.1, where users would set discovery.type to use ec2 hosts provider
93-
return Collections.singletonMap(GCE, () ->
94-
new ZenDiscovery(settings, threadPool, transportService, namedWriteableRegistry, masterService, clusterApplier,
95-
clusterSettings, hostsProvider, allocationService));
96-
}
77+
9778

9879
@Override
9980
public Map<String, Supplier<UnicastHostsProvider>> getZenHostsProviders(TransportService transportService,
@@ -122,21 +103,7 @@ public List<Setting<?>> getSettings() {
122103
GceInstancesService.MAX_WAIT_SETTING);
123104
}
124105

125-
@Override
126-
public Settings additionalSettings() {
127-
// For 5.0, the hosts provider was "zen", but this was before the discovery.zen.hosts_provider
128-
// setting existed. This check looks for the legacy setting, and sets hosts provider if set
129-
String discoveryType = DiscoveryModule.DISCOVERY_TYPE_SETTING.get(settings);
130-
if (discoveryType.equals(GCE)) {
131-
deprecationLogger.deprecated("Using " + DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey() +
132-
" setting to set hosts provider is deprecated. " +
133-
"Set \"" + DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING.getKey() + ": " + GCE + "\" instead");
134-
if (DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING.exists(settings) == false) {
135-
return Settings.builder().put(DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING.getKey(), GCE).build();
136-
}
137-
}
138-
return Settings.EMPTY;
139-
}
106+
140107

141108
@Override
142109
public void close() throws IOException {

plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceDiscoverTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ protected Settings nodeSettings(int nodeOrdinal) {
9090
throw new RuntimeException(e);
9191
}
9292
return Settings.builder().put(super.nodeSettings(nodeOrdinal))
93-
.put("discovery.type", "gce")
93+
.put("discovery.zen.hosts_provider", "gce")
9494
.put("path.logs", resolve)
9595
.put("transport.tcp.port", 0)
9696
.put("node.portsfile", "true")

0 commit comments

Comments
 (0)