-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Add deprecation info and warnings for an empty TIER_PREFERENCE #79305
Add deprecation info and warnings for an empty TIER_PREFERENCE #79305
Conversation
so that it's available to use for a check that wants to use it
Strings and other details obviously placeholder
Strings and other details obviously placeholder
They don't like the new warning, but we can shortcut it by adding a tier preference.
Pinging @elastic/es-data-management (Team:Data Management) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments, otherwise this looks good.
// if we're not enforcing the tier preference, then maybe warn | ||
if (preferredTiers.isEmpty()) { | ||
if (DataTier.dataNodesWithoutAllDataRoles(currentState).isEmpty() == false) { | ||
DEPRECATION_LOGGER.warn(DeprecationCategory.INDICES /*maybe OTHER? */, "index_without_tier_preference", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think INDICES
is fine here, though we could also consider SETTINGS
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍, 14f1984
@@ -1102,6 +1103,16 @@ public void testDeprecateSimpleFS() { | |||
"as it offers superior or equivalent performance to [simplefs]."); | |||
} | |||
|
|||
public void testDeprecateNoTierPreference() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if you should bake this into testEnforceDefaultTierPreference
instead. I think that test method will have to deal with deprecation warnings anyway and it sort of tests all the relevant cases (also want to ensure you get no deprecation warnings when there is a resulting tier preference).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point, I think I've accomplished what you're getting at via 2b11293.
return ClusterState.builder(ClusterState.EMPTY_STATE).nodes(discoBuilder.build()).build(); | ||
} | ||
|
||
public void testDataNodesWithoutAllDataRoles() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we move this test method before the helper method above? That feels like a more natural reading order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing, 2a16334
newNode(0, org.elasticsearch.core.Map.of(), org.elasticsearch.core.Set.of(DiscoveryNodeRole.MASTER_ROLE)), | ||
newNode(1, org.elasticsearch.core.Map.of(), org.elasticsearch.core.Set.of(DiscoveryNodeRole.DATA_ROLE)), | ||
newNode(2, org.elasticsearch.core.Map.of(), allDataRoles), | ||
newNode(3, org.elasticsearch.core.Map.of(), org.elasticsearch.core.Set.of(DiscoveryNodeRole.DATA_FROZEN_NODE_ROLE)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps add one with nearly all roles, something like:
newNode(4, org.elasticsearch.core.Map.of(), randomValueOtherThan(ALL_DATA_TIERS, () -> randomSubSetOf(between(1, ALL_DATA_TIERS.size()-1), ALL_DATA_TIERS)));
You can then validate that you get the node out but no need to validate the roles (just the id/name).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, thanks for the suggestion, 0065a23
@@ -174,4 +175,9 @@ private DeprecationChecks() { | |||
public interface NodeDeprecationCheck<A, B, C, D, R> { | |||
R apply(A first, B second, C third, D fourth); | |||
} | |||
|
|||
@FunctionalInterface | |||
public interface IndexDeprecationCheck<A, B, R> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I follow why it is beneficial to have this be generic, can we not just make apply
take cluster-state and index-metadata as args end return an IndexDeprecationIssue
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohhhhh, yup, I see it now. I tried to mirror what was in place for the NodeDeprecationCheck
, but indeed that's only the way it is because there's not a java.util.QuadFunction
. Replaced with BiFunction
in a963286.
if (tierPreference.isEmpty()) { | ||
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, | ||
"some message here", | ||
"https://www.elastic.co/some/url/here.html", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should ensure this URL points to a good page describing the mandatory tier preference migration. I think just getting some page link to tier preference in for now is fine though, we can then iterate on the docs for this and update the link.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
902f998, good suggestion, I've added a link to the data tiers page for now, because there's some discussion of the setting there (incidentally, some discussion that will need to get updated, in light of the changes from this and the other related PRs).
@@ -671,4 +697,43 @@ public void testFrozenIndex() { | |||
) | |||
)); | |||
} | |||
|
|||
public static ClusterState clusterStateWithoutAllDataRoles() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅, 2f5d9cd
return ClusterState.builder(ClusterState.EMPTY_STATE).nodes(discoBuilder.build()).build(); | ||
} | ||
|
||
public void testEmptyDataTierPreference() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: move test method before helper method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, 2a16334
public void testEmptyDataTierPreference() { | ||
Settings.Builder settings = settings(Version.CURRENT); | ||
settings.put(DataTier.TIER_PREFERENCE_SETTING.getKey(), " "); | ||
IndexMetadata indexMetadata = IndexMetadata.builder("test").settings(settings).numberOfShards(1).numberOfReplicas(0).build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we randomize shard and replica count? Since they are irrelevant here, we might as well signal that by randomizing them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely, 0812b95
"some message here", | ||
"https://www.elastic.co/some/url/here.html", | ||
"some details here", false, null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of this should contain the index name I think (once you adjust the message).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
902f998, we can still iterate on the exact words, but indeed the index name is there.
and rewrite the set matching to use hamcrest more heavily -- it was easy enough to handle a set of one item manually with an iterator, but with two items in the picture it's a bit annoying to do 'by hand'
We don't need a purpose-built interface for these.
If the aggregated settings end up not containing a tier preference, and the cluster has a node without all the data roles, then we should emit a warning. For convenience, the test randomly chooses between an empty cluster state and one that doesn't have all the data roles, so the final condition is written in terms of merely not being the empty state (since the alternative is always one that doesn't have all the data roles, at least in the universe of this test).
We can iterate on these until we get to something that's just right, but this at least gives us a start.
if (tierPreference.isEmpty()) { | ||
String indexName = indexMetadata.getIndex().getName(); | ||
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, | ||
"index [" + indexName + "] does not have a [" + DataTier.TIER_PREFERENCE + "] setting, " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, this isn't the final wording -- there's still an implied run through the overall 7.x and 8.0 docs for this that is coming, and I think rewording these messages to their 100% final form fits in with the intent of that (as yet to be written) PR.
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, | ||
"index [" + indexName + "] does not have a [" + DataTier.TIER_PREFERENCE + "] setting, " + | ||
"in 8.0 this setting will be required for all indices and may not be empty or null.", | ||
"https://www.elastic.co/guide/en/elasticsearch/reference/current/data-tiers.html", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also we're generating shortened URLs for all of the deprecation info API URLs like this. The pattern we've been following is "https://ela.st/es-deprecation-7-", and then we'll map that to a concrete URL. Also, we're trying to make sure that all of the concrete URLs go to something fixed in 7, like "https://www.elastic.co/guide/en/elasticsearch/reference/7.16/data-tiers.html"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, this isn't the final URL, it's just a glorified placeholder -- the right docs don't really exist yet. #79305 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, with the caveat that we need to make sure to return to the deprecation info URL and message at some point soon.
@elasticmachine update branch |
Part of #76147
On 7.x, for clusters that have data nodes that don't have all data roles (e.g. a cluster with a dedicated hot tier would mean those nodes had
data_hot
but not all the otherdata_...
roles), we want to emit deprecation warnings when an index is created that doesn't have a tier preference, and raise any such previously created indices with deprecation info.Note: I've got the logic mostly nailed down here, or so I think, and there are some reasonable tests as well. Clearly the strings for the warnings and info are placeholders -- I'll take another swing at them on Monday. For everything else, though, feel free to ignore the 'WIP' tag to the right, this is intended to be mostly reviewable.