Skip to content

Commit e00c099

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) (cherry picked from commit 7a8c7b0) Conflicts: src/main/java/org/elasticsearch/discovery/ec2/Ec2Discovery.java
1 parent 16d376e commit e00c099

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.elasticsearch.cluster.ClusterName;
2323
import org.elasticsearch.cluster.ClusterService;
24+
import org.elasticsearch.cluster.settings.ClusterDynamicSettings;
2425
import org.elasticsearch.cluster.settings.DynamicSettings;
2526
import org.elasticsearch.common.inject.Inject;
2627
import org.elasticsearch.common.settings.Settings;
@@ -41,7 +42,7 @@ public class Ec2Discovery extends ZenDiscovery {
4142
public Ec2Discovery(Settings settings, ClusterName clusterName, ThreadPool threadPool, TransportService transportService,
4243
ClusterService clusterService, NodeSettingsService nodeSettingsService, ZenPingService pingService,
4344
DiscoverySettings discoverySettings,
44-
ElectMasterService electMasterService, DynamicSettings dynamicSettings) {
45+
ElectMasterService electMasterService, @ClusterDynamicSettings DynamicSettings dynamicSettings) {
4546
super(settings, clusterName, threadPool, transportService, clusterService, nodeSettingsService,
4647
pingService, electMasterService, discoverySettings, dynamicSettings);
4748
}
Lines changed: 63 additions & 0 deletions
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)