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

Adding feature to exclude indexes starting with dot from shard validator #4695

Merged
merged 11 commits into from
Oct 19, 2022

Conversation

nishchay21
Copy link
Contributor

@nishchay21 nishchay21 commented Oct 6, 2022

Signed-off-by: Nishchay Malhotra nishcha@amazon.com

Description

The Current PR helps in solving the issue #4675.

Currently, all plugins do not follow a standard method of inheriting the system indices and are not ignored during the shard limit validation phase. The goal of this PR is to exempt indexes starting with a '.' character to be ignored during this shard limit validation phase.

Further, this PR also adds a cluster setting "cluster.ignore_hidden_indexes" which works as a gated mechanism for the feature to be enabled or disabled. This is a dynamic cluster setting which takes in a boolean value. If the setting is set to true the indexes starting with the '.' character are ignored otherwise considered like other normal indexes. Adding to this the default value of this is added to be true so that the indexes created with '.' are ignored if this setting is not explicitly set.

This is in continuation to PR #4674 as the previous PR has some DCO issue

Issues Resolved

#4675 [Add feature to ignore indexes starting with dot on shard limit validation]

Check List

  • New functionality includes testing.
  • All tests pass
  • New functionality has been documented.
  • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Nishchay Malhotra <nishcha@amazon.com>
Signed-off-by: Nishchay Malhotra <nishcha@amazon.com>
@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2022

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Nishchay Malhotra <nishcha@amazon.com>
@@ -134,6 +134,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Addition of Doc values on the GeoShape Field
- Addition of GeoShape ValueSource level code interfaces for accessing the DocValues.
- Addition of Missing Value feature in the GeoShape Aggregations.
- Added feature to ignore indexes starting with dot during shard limit validation.([#4695](https://github.com/opensearch-project/OpenSearch/pull/4695))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the parent comment that is the reason it looks distorted from above comments as those are sub comments.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2022

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2022

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

github-actions bot commented Oct 7, 2022

Gradle Check (Jenkins) Run Completed with:

@nishchay21 nishchay21 marked this pull request as ready for review October 7, 2022 04:27
@nishchay21 nishchay21 requested review from a team and reta as code owners October 7, 2022 04:27
.put(SETTING_NUMBER_OF_REPLICAS, counts.getFirstIndexReplicas())
.build()
);

Copy link
Member

@ashking94 ashking94 Oct 7, 2022

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 add assertions around the max shard per node setting value and the total number of shards created so far.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ACK will add

verifyException(dataNodes, counts, e);
}
ClusterState clusterState = client().admin().cluster().prepareState().get().getState();
assertTrue(clusterState.getMetadata().hasIndex(".test-index"));
Copy link
Member

Choose a reason for hiding this comment

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

Lets add an assertion here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ACK will add

private void setIgnoreHiddenIndex(boolean ignoreHiddenIndex) {
try {
ClusterUpdateSettingsResponse response;
if (frequently()) {
Copy link
Member

Choose a reason for hiding this comment

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

can we revisit if the usage of frequently is required here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes we will check if for both persistent and transient the setting is getting applied.

response = client().admin()
.cluster()
.prepareUpdateSettings()
.setTransientSettings(Settings.builder().put(shardsPerNodeKey, ignoreHiddenIndex).build())
Copy link
Member

Choose a reason for hiding this comment

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

It should be ignoreHiddenIndexKey in put of the setting builder.

* @param indexName The index which needs to be validated.
*/
private boolean validateHiddenIndex(String indexName) {
return this.ignoreHiddenIndexes && indexName.charAt(0) == '.';
Copy link
Member

Choose a reason for hiding this comment

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

indexName.charAt(0) == '.' could this be little more generic where we could have pattern match or list of pattern match to allow user customisations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will only be done for hidden and system indexes and index names starting with a dot should be reserved for hidden and system indices

Copy link
Collaborator

Choose a reason for hiding this comment

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

should we exclude datastream indices from this ? we can use BACKING_INDEX_PREFIX to match prefix for it .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack will add that

Copy link
Collaborator

Choose a reason for hiding this comment

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

hidden should be index.hidden in index metadata

Copy link
Member

@ashking94 ashking94 left a comment

Choose a reason for hiding this comment

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

Please make the necessary changes.

Signed-off-by: Nishchay Malhotra <nishcha@amazon.com>
@github-actions
Copy link
Contributor

github-actions bot commented Oct 7, 2022

Gradle Check (Jenkins) Run Completed with:

@anasalkouz
Copy link
Member

Is this a backward compatible change? Can OpenSearch's users create indexes started with dot?

Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

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

See below re:backwards incompatible change. It looks like such.

Signed-off-by: Nishchay Malhotra <nishcha@amazon.com>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Nishchay Malhotra <nishcha@amazon.com>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Copy link
Member

@ashking94 ashking94 left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -252,6 +252,7 @@ public void apply(Settings value, Settings current, Settings previous) {
Metadata.SETTING_READ_ONLY_SETTING,
Metadata.SETTING_READ_ONLY_ALLOW_DELETE_SETTING,
ShardLimitValidator.SETTING_CLUSTER_MAX_SHARDS_PER_NODE,
ShardLimitValidator.SETTING_CLUSTER_IGNORE_HIDDEN_INDEXES,
Copy link
Collaborator

Choose a reason for hiding this comment

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

indices beginning with . are not necessarily hidden and vice-versa. index.hidden is a separate index level setting. Many opensearch plugin use that like cross-cluster and many don't like security-plugin. Should we say dot_indices ?

Copy link
Contributor Author

@nishchay21 nishchay21 Oct 18, 2022

Choose a reason for hiding this comment

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

Previously named this to dot_index however was asked to rename as mentioned in this close PR #4674

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Bukhtawar : what is your take on using hidden or dot ?

Copy link
Collaborator

@Bukhtawar Bukhtawar Oct 19, 2022

Choose a reason for hiding this comment

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

dot indices have been deprecated so going forward we should use hidden and system indices only. For 2.x we might still have to support dot indices. Any reason why security plugin is still using dot index?

I am fine with dot index for the purpose of this PR and backporting to 2.x but please open a PR to deprecate dot indices going forward

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Bukhtawar @gbbafna so should we change to dot or go with hidden ??

* @param indexName The index which needs to be validated.
*/
private boolean validateHiddenIndex(String indexName) {
return this.ignoreHiddenIndexes && indexName.charAt(0) == '.';
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we exclude datastream indices from this ? we can use BACKING_INDEX_PREFIX to match prefix for it .

Signed-off-by: Nishchay Malhotra <nishcha@amazon.com>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

…ore_dot_indexes

Signed-off-by: Nishchay Malhotra <nishcha@amazon.com>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@codecov-commenter
Copy link

Codecov Report

Merging #4695 (8e70553) into main (f5ea1a4) will decrease coverage by 0.02%.
The diff coverage is 77.77%.

@@             Coverage Diff              @@
##               main    #4695      +/-   ##
============================================
- Coverage     70.59%   70.57%   -0.03%     
+ Complexity    57637    57594      -43     
============================================
  Files          4661     4661              
  Lines        277152   277160       +8     
  Branches      40550    40550              
============================================
- Hits         195667   195607      -60     
- Misses        65124    65180      +56     
- Partials      16361    16373      +12     
Impacted Files Coverage Δ
...rg/opensearch/common/settings/ClusterSettings.java 91.89% <ø> (ø)
...va/org/opensearch/indices/ShardLimitValidator.java 96.22% <77.77%> (-3.78%) ⬇️
...g/opensearch/index/analysis/CharFilterFactory.java 0.00% <0.00%> (-100.00%) ⬇️
...search/indices/recovery/RecoveryTargetHandler.java 0.00% <0.00%> (-100.00%) ⬇️
...ava/org/opensearch/action/NoSuchNodeException.java 0.00% <0.00%> (-50.00%) ⬇️
.../action/admin/indices/flush/ShardFlushRequest.java 50.00% <0.00%> (-50.00%) ⬇️
...opensearch/persistent/PersistentTasksExecutor.java 22.22% <0.00%> (-44.45%) ⬇️
.../search/aggregations/pipeline/HoltLinearModel.java 20.33% <0.00%> (-42.38%) ⬇️
.../java/org/opensearch/search/dfs/AggregatedDfs.java 54.83% <0.00%> (-41.94%) ⬇️
...cluster/coordination/PublishClusterStateStats.java 33.33% <0.00%> (-37.51%) ⬇️
... and 471 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Further also validates if the cluster.ignore_dot_indexes is set to true.
If so then it does not validate any index which starts with '.'.
*/
if ((systemIndices.validateSystemIndex(indexName) || validateDotIndex(indexName)) && !isDataStreamIndex(indexName)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't the first condition a subset of the dot index

Copy link
Contributor Author

@nishchay21 nishchay21 Oct 19, 2022

Choose a reason for hiding this comment

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

Yes it would be but to have consistency that system index are also ignore have not removed that completely. Also if the setting is false we still need system indexes to be ignored

Comment on lines 180 to 182
private boolean validateDotIndex(String indexName) {
return this.ignoreDotIndexes && indexName.charAt(0) == '.';
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

lets not club both the logic in this method looks confusing to read, just have indexName.charAt(0) == '.'

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@dblock
Copy link
Member

dblock commented Oct 19, 2022

Looks like a transient failure in precommit checks, kicked it.

@Bukhtawar Bukhtawar merged commit 04eb817 into opensearch-project:main Oct 19, 2022
@Bukhtawar Bukhtawar added the backport 2.x Backport to 2.x branch label Oct 27, 2022
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 27, 2022
…tor (#4695)

* Adding feature to exclude indexes starting with dot from shard validator

Signed-off-by: Nishchay Malhotra <nishcha@amazon.com>
(cherry picked from commit 04eb817)
Bukhtawar pushed a commit that referenced this pull request Oct 29, 2022
…tor (#4695) (#4953)

* Adding feature to exclude indexes starting with dot from shard validator

Signed-off-by: Nishchay Malhotra <nishcha@amazon.com>
(cherry picked from commit 04eb817)
ashking94 pushed a commit to ashking94/OpenSearch that referenced this pull request Nov 7, 2022
…tor (opensearch-project#4695)

* Adding feature to exclude indexes starting with dot from shard validator

Signed-off-by: Nishchay Malhotra <nishcha@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants