Skip to content

Commit bcd6ec2

Browse files
committed
Have VotingOnlyNodePlugin always enabled
1 parent e284426 commit bcd6ec2

File tree

5 files changed

+6
-39
lines changed

5 files changed

+6
-39
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,6 @@ private XPackSettings() {
117117
/** Setting for enabling or disabling vectors. Defaults to true. */
118118
public static final Setting<Boolean> VECTORS_ENABLED = Setting.boolSetting("xpack.vectors.enabled", true, Setting.Property.NodeScope);
119119

120-
/** Setting for enabling or disabling the voting-only-node functionality. Needs to be enabled on both voting-only nodes and regular
121-
* master-eligible nodes for the voting-only functionality to work correctly. Defaults to true. */
122-
public static final Setting<Boolean> VOTING_ONLY_ENABLED = Setting.boolSetting("xpack.voting_only.enabled", true,
123-
Setting.Property.NodeScope);
124-
125120
/*
126121
* SSL settings. These are the settings that are specifically registered for SSL. Many are private as we do not explicitly use them
127122
* but instead parse based on a prefix (eg *.ssl.*)
@@ -213,7 +208,6 @@ public static List<Setting<?>> getAllSettings() {
213208
settings.add(INDEX_LIFECYCLE_ENABLED);
214209
settings.add(DATA_FRAME_ENABLED);
215210
settings.add(VECTORS_ENABLED);
216-
settings.add(VOTING_ONLY_ENABLED);
217211
return Collections.unmodifiableList(settings);
218212
}
219213

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/votingonly/VotingOnlyNodeFeatureSetUsage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public VotingOnlyNodeFeatureSetUsage(StreamInput input) throws IOException {
1616
super(input);
1717
}
1818

19-
public VotingOnlyNodeFeatureSetUsage(boolean available, boolean enabled) {
20-
super(XPackField.VOTING_ONLY, available, enabled);
19+
public VotingOnlyNodeFeatureSetUsage(boolean available) {
20+
super(XPackField.VOTING_ONLY, available, true);
2121
}
2222
}

x-pack/plugin/voting-only-node/src/main/java/org/elasticsearch/cluster/coordination/VotingOnlyNodeFeatureSet.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,23 @@
1212
import org.elasticsearch.cluster.service.ClusterService;
1313
import org.elasticsearch.common.Nullable;
1414
import org.elasticsearch.common.inject.Inject;
15-
import org.elasticsearch.common.settings.Settings;
1615
import org.elasticsearch.license.XPackLicenseState;
1716
import org.elasticsearch.protocol.xpack.XPackUsageRequest;
1817
import org.elasticsearch.threadpool.ThreadPool;
1918
import org.elasticsearch.transport.TransportService;
2019
import org.elasticsearch.xpack.core.XPackFeatureSet;
2120
import org.elasticsearch.xpack.core.XPackField;
22-
import org.elasticsearch.xpack.core.XPackSettings;
2321
import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction;
2422
import org.elasticsearch.xpack.core.action.XPackUsageFeatureResponse;
2523
import org.elasticsearch.xpack.core.action.XPackUsageFeatureTransportAction;
2624
import org.elasticsearch.xpack.core.votingonly.VotingOnlyNodeFeatureSetUsage;
2725

2826
public class VotingOnlyNodeFeatureSet implements XPackFeatureSet {
2927

30-
private final boolean enabled;
3128
private final XPackLicenseState licenseState;
3229

3330
@Inject
34-
public VotingOnlyNodeFeatureSet(Settings settings, @Nullable XPackLicenseState licenseState) {
35-
this.enabled = XPackSettings.VOTING_ONLY_ENABLED.get(settings);
31+
public VotingOnlyNodeFeatureSet(@Nullable XPackLicenseState licenseState) {
3632
this.licenseState = licenseState;
3733
}
3834

@@ -48,29 +44,27 @@ public boolean available() {
4844

4945
@Override
5046
public boolean enabled() {
51-
return enabled;
47+
return true;
5248
}
5349

5450
public static class UsageTransportAction extends XPackUsageFeatureTransportAction {
5551

56-
private final Settings settings;
5752
private final XPackLicenseState licenseState;
5853

5954
@Inject
6055
public UsageTransportAction(TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
6156
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver,
62-
Settings settings, XPackLicenseState licenseState) {
57+
XPackLicenseState licenseState) {
6358
super(XPackUsageFeatureAction.VOTING_ONLY_NODE.name(), transportService, clusterService,
6459
threadPool, actionFilters, indexNameExpressionResolver);
65-
this.settings = settings;
6660
this.licenseState = licenseState;
6761
}
6862

6963
@Override
7064
protected void masterOperation(XPackUsageRequest request, ClusterState state, ActionListener<XPackUsageFeatureResponse> listener) {
7165
final boolean available = licenseState.isVotingOnlyAllowed();
7266
final VotingOnlyNodeFeatureSetUsage usage =
73-
new VotingOnlyNodeFeatureSetUsage(available, XPackSettings.VOTING_ONLY_ENABLED.get(settings));
67+
new VotingOnlyNodeFeatureSetUsage(available);
7468
listener.onResponse(new XPackUsageFeatureResponse(usage));
7569
}
7670
}

x-pack/plugin/voting-only-node/src/main/java/org/elasticsearch/cluster/coordination/VotingOnlyNodePlugin.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import org.elasticsearch.transport.TransportResponseHandler;
4343
import org.elasticsearch.watcher.ResourceWatcherService;
4444
import org.elasticsearch.xpack.core.XPackPlugin;
45-
import org.elasticsearch.xpack.core.XPackSettings;
4645
import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction;
4746

4847
import java.io.IOException;
@@ -96,10 +95,6 @@ public List<Setting<?>> getSettings() {
9695

9796
@Override
9897
public Set<DiscoveryNodeRole> getRoles() {
99-
if (VOTING_ONLY_NODE_SETTING.exists(settings) && XPackSettings.VOTING_ONLY_ENABLED.get(settings) == false) {
100-
throw new IllegalStateException(XPackSettings.VOTING_ONLY_ENABLED.getKey() + " must be set to true to use the " +
101-
VOTING_ONLY_NODE_SETTING.getKey() + " setting");
102-
}
10398
if (isVotingOnlyNode && Node.NODE_MASTER_SETTING.get(settings) == false) {
10499
throw new IllegalStateException("voting-only node must be master-eligible");
105100
}
@@ -129,9 +124,6 @@ public Collection<Module> createGuiceModules() {
129124

130125
@Override
131126
public Map<String, ElectionStrategy> getElectionStrategies() {
132-
if (XPackSettings.VOTING_ONLY_ENABLED.get(settings) == false) {
133-
return Collections.emptyMap();
134-
}
135127
return Collections.singletonMap(VOTING_ONLY_ELECTION_STRATEGY, new VotingOnlyNodeElectionStrategy());
136128
}
137129

@@ -151,9 +143,6 @@ public AsyncSender interceptSender(AsyncSender sender) {
151143

152144
@Override
153145
public Settings additionalSettings() {
154-
if (XPackSettings.VOTING_ONLY_ENABLED.get(settings) == false) {
155-
return Settings.EMPTY;
156-
}
157146
return Settings.builder().put(DiscoveryModule.ELECTION_STRATEGY_SETTING.getKey(), VOTING_ONLY_ELECTION_STRATEGY).build();
158147
}
159148

x-pack/plugin/voting-only-node/src/test/java/org/elasticsearch/cluster/coordination/VotingOnlyNodePluginTests.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,6 @@ public void testRequireVotingOnlyNodeToBeMasterEligible() {
3939
assertThat(ise.getMessage(), containsString("voting-only node must be master-eligible"));
4040
}
4141

42-
public void testRequireVotingOnlyNodeToHaveXPackSettingEnabled() {
43-
internalCluster().setBootstrapMasterNodeIndex(0);
44-
IllegalStateException ise = expectThrows(IllegalStateException.class, () -> internalCluster().startNode(Settings.builder()
45-
.put(VotingOnlyNodePlugin.VOTING_ONLY_NODE_SETTING.getKey(), true)
46-
.put(XPackSettings.VOTING_ONLY_ENABLED.getKey(), false)
47-
.build()));
48-
assertThat(ise.getMessage(), containsString(XPackSettings.VOTING_ONLY_ENABLED.getKey() + " must be set to true to use the " +
49-
VotingOnlyNodePlugin.VOTING_ONLY_NODE_SETTING.getKey() + " setting"));
50-
}
51-
5242
public void testVotingOnlyNodeStats() throws Exception {
5343
internalCluster().setBootstrapMasterNodeIndex(0);
5444
internalCluster().startNodes(2);

0 commit comments

Comments
 (0)