Skip to content

Commit 7a8c7b0

Browse files
committed
Fix non working update dynamic settings
Described in elastic/elasticsearch#10614, it's not possible with cloud discovery plugin to update dynamic settings anymore. ```sh curl -XPUT localhost:9200/_cluster/settings -d '{ "persistent" : { "discovery.zen.minimum_master_nodes" : 3 }, "transient" : { "discovery.zen.minimum_master_nodes" : 3 } }' ``` gives ```json {"acknowledged":true,"persistent":{},"transient":{}} ``` This patch makes that working again. (cherry picked from commit 37d6897)
1 parent 9809af5 commit 7a8c7b0

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

src/main/java/org/elasticsearch/discovery/ec2/Ec2Discovery.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.elasticsearch.cluster.ClusterName;
2525
import org.elasticsearch.cluster.ClusterService;
2626
import org.elasticsearch.cluster.node.DiscoveryNodeService;
27+
import org.elasticsearch.cluster.settings.ClusterDynamicSettings;
2728
import org.elasticsearch.cluster.settings.DynamicSettings;
2829
import org.elasticsearch.common.collect.ImmutableList;
2930
import org.elasticsearch.common.inject.Inject;
@@ -47,7 +48,7 @@ public class Ec2Discovery extends ZenDiscovery {
4748
public Ec2Discovery(Settings settings, ClusterName clusterName, ThreadPool threadPool, TransportService transportService,
4849
ClusterService clusterService, NodeSettingsService nodeSettingsService, ZenPingService pingService,
4950
DiscoveryNodeService discoveryNodeService, AwsEc2Service ec2Service, DiscoverySettings discoverySettings,
50-
ElectMasterService electMasterService, DynamicSettings dynamicSettings,
51+
ElectMasterService electMasterService, @ClusterDynamicSettings DynamicSettings dynamicSettings,
5152
Version version) {
5253
super(settings, clusterName, threadPool, transportService, clusterService, nodeSettingsService,
5354
discoveryNodeService, pingService, electMasterService, discoverySettings, dynamicSettings);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.discovery.ec2;
21+
22+
23+
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse;
24+
import org.elasticsearch.cloud.aws.AbstractAwsTest;
25+
import org.elasticsearch.cloud.aws.AbstractAwsTest.AwsTest;
26+
import org.elasticsearch.common.settings.Settings;
27+
import org.elasticsearch.plugins.PluginsService;
28+
import org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope;
29+
import org.elasticsearch.test.ElasticsearchIntegrationTest.Scope;
30+
import org.junit.Test;
31+
32+
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
33+
import static org.hamcrest.CoreMatchers.is;
34+
35+
/**
36+
* Just an empty Node Start test to check eveything if fine when
37+
* starting.
38+
* This test requires AWS to run.
39+
*/
40+
@AwsTest
41+
@ClusterScope(scope = Scope.TEST, numDataNodes = 0, numClientNodes = 0, transportClientRatio = 0.0)
42+
public class Ec2DiscoveryUpdateSettingsITest extends AbstractAwsTest {
43+
44+
@Test
45+
public void testMinimumMasterNodesStart() {
46+
Settings nodeSettings = settingsBuilder()
47+
.put("plugins." + PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, true)
48+
.put("cloud.enabled", true)
49+
.put("discovery.type", "ec2")
50+
.build();
51+
internalCluster().startNode(nodeSettings);
52+
53+
// We try to update minimum_master_nodes now
54+
ClusterUpdateSettingsResponse response = client().admin().cluster().prepareUpdateSettings()
55+
.setPersistentSettings(settingsBuilder().put("discovery.zen.minimum_master_nodes", 1))
56+
.setTransientSettings(settingsBuilder().put("discovery.zen.minimum_master_nodes", 1))
57+
.get();
58+
59+
Integer min = response.getPersistentSettings().getAsInt("discovery.zen.minimum_master_nodes", null);
60+
assertThat(min, is(1));
61+
}
62+
63+
}

0 commit comments

Comments
 (0)