-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fixing _list/shards API for closed indices #16606
base: main
Are you sure you want to change the base?
Fixing _list/shards API for closed indices #16606
Conversation
❌ Gradle check result for c62e5f2: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
c62e5f2
to
691803c
Compare
❌ Gradle check result for 691803c: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: Harsh Garg <[email protected]>
Signed-off-by: Harsh Garg <[email protected]>
Signed-off-by: Harsh Garg <[email protected]>
691803c
to
4663f2b
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16606 +/- ##
============================================
- Coverage 72.15% 72.14% -0.02%
- Complexity 65145 65185 +40
============================================
Files 5315 5318 +3
Lines 303573 303832 +259
Branches 43925 43959 +34
============================================
+ Hits 219039 219189 +150
- Misses 66587 66656 +69
- Partials 17947 17987 +40 ☔ View full report in Codecov by Sentry. |
CountDownLatch latch = new CountDownLatch(1); | ||
client().execute(CatShardsAction.INSTANCE, shardsRequest, new ActionListener<CatShardsResponse>() { | ||
@Override | ||
public void onResponse(CatShardsResponse catShardsResponse) { | ||
List<ShardRouting> shardRoutings = catShardsResponse.getResponseShards(); | ||
assertFalse(shardRoutings.stream().anyMatch(shard -> shard.getIndexName().equals("test-3"))); | ||
latch.countDown(); | ||
} | ||
|
||
@Override | ||
public void onFailure(Exception e) { | ||
fail(); | ||
latch.countDown(); | ||
} | ||
}); | ||
latch.await(); | ||
} |
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 you can skip the latch by using the variant the returns a future, something like:
ActionFuture<CatShardsResponse> response = client().execute(CatShardsAction.INSTANCE, shardsRequest);
List<ShardRouting> shardRoutings = response.get().getResponseShards();
assertFalse(shardRoutings.stream().anyMatch(shard -> shard.getIndexName().equals("test-3")));
} | ||
|
||
private static Predicate<IndexMetadata> indexNameFilter(String lastIndexName) { | ||
return metadata -> metadata.getIndex().getName().equals(lastIndexName); | ||
} | ||
|
||
private static Predicate<IndexMetadata> indexStateFilter(IndicesOptions indicesOptions) { | ||
if (Objects.isNull(indicesOptions) || !indicesOptions.forbidClosedIndices()) { |
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 Objects.isNull
exists to use as a predicate. The canonical way to do this is just indicesOptions == null
Description
_list/shards API throws index_closed_exception whenever the cluster has closed indices. This change is to resolve and ignore the closed indices from getting explicitly passed to IndicesStatsAction.
Related Issues
Resolves #16626
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.