-
Notifications
You must be signed in to change notification settings - Fork 1.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
Adding feature to exclude indexes starting with dot from shard validator #4695
Adding feature to exclude indexes starting with dot from shard validator #4695
Conversation
Signed-off-by: Nishchay Malhotra <nishcha@amazon.com>
Signed-off-by: Nishchay Malhotra <nishcha@amazon.com>
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)) |
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.
This is the parent comment that is the reason it looks distorted from above comments as those are sub comments.
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
.put(SETTING_NUMBER_OF_REPLICAS, counts.getFirstIndexReplicas()) | ||
.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.
It would be good to add assertions around the max shard per node setting value and the total number of shards created so far.
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.
ACK will add
verifyException(dataNodes, counts, e); | ||
} | ||
ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); | ||
assertTrue(clusterState.getMetadata().hasIndex(".test-index")); |
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.
Lets add an assertion here as well.
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.
ACK will add
private void setIgnoreHiddenIndex(boolean ignoreHiddenIndex) { | ||
try { | ||
ClusterUpdateSettingsResponse response; | ||
if (frequently()) { |
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 revisit if the usage of frequently is required here?
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.
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()) |
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.
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) == '.'; |
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.
indexName.charAt(0) == '.'
could this be little more generic where we could have pattern match or list of pattern match to allow user customisations?
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.
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
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.
should we exclude datastream indices from this ? we can use BACKING_INDEX_PREFIX
to match prefix for it .
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.
Ack will add that
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.
hidden should be index.hidden in index metadata
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.
Please make the necessary changes.
Signed-off-by: Nishchay Malhotra <nishcha@amazon.com>
Gradle Check (Jenkins) Run Completed with:
|
Is this a backward compatible change? Can OpenSearch's users create indexes started with dot? |
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.
See below re:backwards incompatible change. It looks like such.
server/src/main/java/org/opensearch/indices/ShardLimitValidator.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Nishchay Malhotra <nishcha@amazon.com>
Gradle Check (Jenkins) Run Completed with:
|
Signed-off-by: Nishchay Malhotra <nishcha@amazon.com>
Gradle Check (Jenkins) Run Completed with:
|
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.
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, |
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.
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
?
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.
Previously named this to dot_index however was asked to rename as mentioned in this close PR #4674
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.
@Bukhtawar : what is your take on using hidden
or dot
?
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.
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
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.
@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) == '.'; |
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.
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>
Gradle Check (Jenkins) Run Completed with:
|
…ore_dot_indexes Signed-off-by: Nishchay Malhotra <nishcha@amazon.com>
Gradle Check (Jenkins) Run Completed with:
|
Codecov Report
@@ 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
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)) { |
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.
Isn't the first condition a subset of the dot index
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.
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
private boolean validateDotIndex(String indexName) { | ||
return this.ignoreDotIndexes && indexName.charAt(0) == '.'; | ||
} |
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.
lets not club both the logic in this method looks confusing to read, just have indexName.charAt(0) == '.'
…itions hold true Signed-off-by: Nishchay Malhotra <nishcha@amazon.com>
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
Looks like a transient failure in precommit checks, kicked it. |
…tor (opensearch-project#4695) * Adding feature to exclude indexes starting with dot from shard validator Signed-off-by: Nishchay Malhotra <nishcha@amazon.com>
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
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.