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

Add deprecation info and warnings for an empty TIER_PREFERENCE #79305

Merged
merged 20 commits into from
Oct 19, 2021

Conversation

joegallo
Copy link
Contributor

@joegallo joegallo commented Oct 16, 2021

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 other data_... 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.

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.
@joegallo joegallo added WIP :Data Management/ILM+SLM Index and Snapshot lifecycle management v7.16.0 labels Oct 16, 2021
@elasticmachine elasticmachine added the Team:Data Management Meta label for data/management team label Oct 16, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

Copy link
Contributor

@henningandersen henningandersen left a 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",
Copy link
Contributor

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.

Copy link
Contributor Author

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() {
Copy link
Contributor

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).

Copy link
Contributor Author

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() {
Copy link
Contributor

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.

Copy link
Contributor Author

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))
Copy link
Contributor

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).

Copy link
Contributor Author

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> {
Copy link
Contributor

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?

Copy link
Contributor Author

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",
Copy link
Contributor

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.

Copy link
Contributor Author

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() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: private?

Copy link
Contributor Author

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() {
Copy link
Contributor

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.

Copy link
Contributor Author

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();
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely, 0812b95

Comment on lines 733 to 735
"some message here",
"https://www.elastic.co/some/url/here.html",
"some details here", false, null)
Copy link
Contributor

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).

Copy link
Contributor Author

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).
@joegallo joegallo requested a review from masseyke October 18, 2021 19:29
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, " +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to get @debadair or @jrodewig or someone from our docs team to weigh in on the wording here. They've recently had an effort to standardize the wording.

Copy link
Contributor Author

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",
Copy link
Member

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"

Copy link
Contributor Author

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)

@joegallo joegallo removed the WIP label Oct 18, 2021
Copy link
Member

@masseyke masseyke left a 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.

@joegallo
Copy link
Contributor Author

@elasticmachine update branch

@joegallo joegallo merged commit 679beda into elastic:7.x Oct 19, 2021
@joegallo joegallo deleted the enforce-default-tier-preference-checks branch October 19, 2021 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Data Management/ILM+SLM Index and Snapshot lifecycle management >deprecation Team:Data Management Meta label for data/management team v7.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants