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

Improve data_tier allocation explanation message #105858

Merged
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 @@ -95,21 +95,18 @@ public static Decision shouldFilter(
);
if (tier.isPresent()) {
String tierName = tier.get();
if (allocationAllowed(tierName, node)) {
if (allocation.debugDecision()) {
return debugYesAllowed(allocation, tierPreference, tierName);
}
return Decision.YES;
assert Strings.hasText(tierName) : "tierName must be not null and non-empty, but was [" + tierName + "]";
if (node.hasRole(DiscoveryNodeRole.DATA_ROLE.roleName())) {
return allocation.debugDecision()
? debugYesAllowed(allocation, tierPreference, DiscoveryNodeRole.DATA_ROLE.roleName())
: Decision.YES;
}
if (allocation.debugDecision()) {
return debugNoRequirementsNotMet(allocation, tierPreference, tierName);
if (node.hasRole(tierName)) {
return allocation.debugDecision() ? debugYesAllowed(allocation, tierPreference, tierName) : Decision.YES;
}
return Decision.NO;
return allocation.debugDecision() ? debugNoRequirementsNotMet(allocation, tierPreference, tierName) : Decision.NO;
}
if (allocation.debugDecision()) {
return debugNoNoNodesAvailable(allocation, tierPreference);
}
return Decision.NO;
return allocation.debugDecision() ? debugNoNoNodesAvailable(allocation, tierPreference) : Decision.NO;
}

private static Decision debugNoNoNodesAvailable(RoutingAllocation allocation, List<String> tierPreference) {
Expand Down Expand Up @@ -278,11 +275,6 @@ static boolean tierNodesPresentConsideringRemovals(String singleTier, DiscoveryN
return false;
}

public static boolean allocationAllowed(String tierName, DiscoveryNode node) {
assert Strings.hasText(tierName) : "tierName must be not null and non-empty, but was [" + tierName + "]";
return node.hasRole(DiscoveryNodeRole.DATA_ROLE.roleName()) || node.hasRole(tierName);
}

public static boolean allocationAllowed(String tierName, Set<DiscoveryNodeRole> roles) {
assert Strings.hasText(tierName) : "tierName must be not null and non-empty, but was [" + tierName + "]";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,16 @@ public void testIndexPrefer() {
)
);
}
}
{
final var state = clusterStateWithIndexAndNodes("data_warm", DiscoveryNodes.builder().add(DATA_NODE).build(), null);

assertAllocationDecision(
state,
DATA_NODE,
Decision.Type.YES,
"index has a preference for tiers [data_warm] and node has tier [data]"
);
}
}

Expand Down