Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix isDedicatedVotingOnlyNode #71358

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,9 @@ protected void doRun() {
}

public static boolean isDedicatedVotingOnlyNode(Set<DiscoveryNodeRole> roles) {
return roles.contains(DiscoveryNodeRole.MASTER_ROLE) && roles.contains(DiscoveryNodeRole.DATA_ROLE) == false &&
roles.stream().anyMatch(role -> role.roleName().equals("voting_only"));
return roles.contains(DiscoveryNodeRole.MASTER_ROLE)
&& roles.stream().noneMatch(DiscoveryNodeRole::canContainData)
&& roles.stream().anyMatch(role -> role.roleName().equals("voting_only"));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import static org.elasticsearch.test.NodeRoles.addRoles;
import static org.elasticsearch.test.NodeRoles.onlyRole;
import static org.elasticsearch.test.NodeRoles.onlyRoles;
import static org.elasticsearch.test.NodeRoles.removeRoles;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;
Expand Down Expand Up @@ -150,8 +151,11 @@ public void testBasicSnapshotRestoreWorkFlow() {
final String dedicatedVotingOnlyNode = internalCluster().startNode(
onlyRoles(Set.of(DiscoveryNodeRole.MASTER_ROLE, VotingOnlyNodePlugin.VOTING_ONLY_NODE_ROLE)));
// voting-only master node that also has data
final String nonDedicatedVotingOnlyNode = internalCluster().startNode(
addRoles(Set.of(VotingOnlyNodePlugin.VOTING_ONLY_NODE_ROLE)));
Settings dataContainingVotingOnlyNodeSettings = addRoles(Set.of(VotingOnlyNodePlugin.VOTING_ONLY_NODE_ROLE));
if (randomBoolean()) {
dataContainingVotingOnlyNodeSettings = removeRoles(dataContainingVotingOnlyNodeSettings, Set.of(DiscoveryNodeRole.DATA_ROLE));
}
final String nonDedicatedVotingOnlyNode = internalCluster().startNode(dataContainingVotingOnlyNodeSettings);

assertAcked(client().admin().cluster().preparePutRepository("test-repo")
.setType("verifyaccess-fs").setSettings(Settings.builder().put("location", randomRepoPath())
Expand Down