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

Use Setting infrastructure for number_of_replicas #56712

Closed
wants to merge 2 commits into from

Conversation

rjernst
Copy link
Member

@rjernst rjernst commented May 13, 2020

The Setting class provides the ability to define a setting, a default
value, along with validation logic. However, there are still many uses
of thhe old getAsXXX methods on Settings. This commit converts one of
those cases, reading the index number_of_replicas setting, so that the
default is not defined in multiple places.

relates #56656
relates #56501

The Setting class provides the ability to define a setting, a default
value, along with validation logic. However, there are still many uses
of thhe old getAsXXX methods on Settings. This commit converts one of
those cases, reading the index number_of_replicas setting, so that the
default is not defined in multiple places.

relates elastic#56656
relates elastic#56501
@rjernst rjernst added :Data Management/Indices APIs APIs to create and manage indices and templates >refactoring v8.0.0 v7.9.0 labels May 13, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features (:Core/Features/Indices APIs)

@elasticmachine elasticmachine added the Team:Data Management Meta label for data/management team label May 13, 2020
@rjernst rjernst requested a review from jasontedor May 13, 2020 19:39
Copy link
Member

@jasontedor jasontedor 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.

if (numberOfReplicas < 0) {
throw new IllegalArgumentException("must specify non-negative number of replicas for index [" + index + "]");
}
int numberOfReplicas = INDEX_NUMBER_OF_REPLICAS_SETTING.get(settings);
Copy link
Member

Choose a reason for hiding this comment

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

This isn't equivalent, since not having this setting set in the metadata is considered illegal.

Copy link
Member

Choose a reason for hiding this comment

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

That is, we want to maintain that these are set upstream, and not fallback to defaults here. We want to do that elsewhere, so that if we somehow end up here without it having been set, it's a bug that we ended up with metadata without having it set.

Copy link
Member Author

Choose a reason for hiding this comment

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

There were two cases before. The first is the missing case. It was never intended to end up here without number of replicas set; it isn't actually an error from the user's perspective. The default was previously handled upstream, but now we are using the default mechanism in Setting. There's no reason to set number of replicas just so it can be passed in here. The second case was the bounds check, which is also handled in the Setting by the minimum value of 0.

Copy link
Member

Choose a reason for hiding this comment

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

We copy/rebuild index metadata in various places (shrink, split, clone, restores, etc.). This check ensures that when we rebuild the index metadata, that we have set the number of replicas (and also we do this for the number of shards), instead of relying on the defaults.

Copy link
Member

Choose a reason for hiding this comment

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

I took at a stab and what I think this should look like in #56801.

@rjernst
Copy link
Member Author

rjernst commented May 15, 2020

closing in favor of #56801

@rjernst rjernst closed this May 15, 2020
@rjernst rjernst deleted the setting_cleanup1 branch May 15, 2020 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Data Management/Indices APIs APIs to create and manage indices and templates >refactoring Team:Data Management Meta label for data/management team v7.9.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants