Skip to content

Commit

Permalink
Merge branch '2.x' into backport/backport-5676
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishikesh1159 authored Jan 4, 2023
2 parents 8fdaca3 + 72a1e58 commit 0541bbb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Added experimental support for extensions ([#5347](https://github.com/opensearch-project/OpenSearch/pull/5347)), ([#5518](https://github.com/opensearch-project/OpenSearch/pull/5518)), ([#5597](https://github.com/opensearch-project/OpenSearch/pull/5597)), ([#5615](https://github.com/opensearch-project/OpenSearch/pull/5615)))
- Add CI bundle pattern to distribution download ([#5348](https://github.com/opensearch-project/OpenSearch/pull/5348))


### Dependencies
- Bump bcpg-fips from 1.0.5.1 to 1.0.7.1 ([#5148](https://github.com/opensearch-project/OpenSearch/pull/5148))
- Bumps `commons-compress` from 1.21 to 1.22 ([#5104](https://github.com/opensearch-project/OpenSearch/pull/5104))
Expand All @@ -33,6 +32,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Bumps `proto-google-common-protos` from 2.8.0 to 2.10.0 ([#5318](https://github.com/opensearch-project/OpenSearch/pull/5318))
- Bumps `protobuf-java` from 3.21.7 to 3.21.9 ([#5319](https://github.com/opensearch-project/OpenSearch/pull/5319))
- Bumps `reactor-netty` from 1.0.18 to 1.1.1 ([#5685](https://github.com/opensearch-project/OpenSearch/pull/5685))
- Bumps `apache-rat` from 0.13 to 0.15 ([#5686](https://github.com/opensearch-project/OpenSearch/pull/5686))

### Changed
- Change http code for DecommissioningFailedException from 500 to 400 ([#5283](https://github.com/opensearch-project/OpenSearch/pull/5283))
Expand All @@ -49,6 +49,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Apply cluster manager throttling settings during bootstrap ([#5524](https://github.com/opensearch-project/OpenSearch/pull/5524))
- Update thresholds map when cluster manager throttling setting is removed ([#5524](https://github.com/opensearch-project/OpenSearch/pull/5524))
- Fix backward compatibility for static cluster manager throttling threshold setting ([#5633](https://github.com/opensearch-project/OpenSearch/pull/5633))
- Fix index exclusion behavior in snapshot restore and clone APIs ([#5626](https://github.com/opensearch-project/OpenSearch/pull/5626))

### Security

[Unreleased 2.x]: https://github.com/opensearch-project/OpenSearch/compare/2.4...2.x
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ dependencies {
api 'com.netflix.nebula:gradle-extra-configurations-plugin:8.0.0'
api 'com.netflix.nebula:nebula-publishing-plugin:4.6.0'
api 'com.netflix.nebula:gradle-info-plugin:7.1.3'
api 'org.apache.rat:apache-rat:0.13'
api 'org.apache.rat:apache-rat:0.15'
api 'commons-io:commons-io:2.7'
api "net.java.dev.jna:jna:5.11.0"
api 'gradle.plugin.com.github.johnrengelman:shadow:7.1.2'
Expand Down
18 changes: 15 additions & 3 deletions server/src/main/java/org/opensearch/snapshots/SnapshotUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
import java.util.Set;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* Snapshot utilities
Expand All @@ -69,9 +71,17 @@ public static List<String> filterIndices(List<String> availableIndices, String[]
if (IndexNameExpressionResolver.isAllIndices(Arrays.asList(selectedIndices))) {
return availableIndices;
}

// Move the exclusions to end of list to ensure they are processed
// after explicitly selected indices are chosen.
final List<String> excludesAtEndSelectedIndices = Stream.concat(
Arrays.stream(selectedIndices).filter(s -> s.isEmpty() || s.charAt(0) != '-'),
Arrays.stream(selectedIndices).filter(s -> !s.isEmpty() && s.charAt(0) == '-')
).collect(Collectors.toUnmodifiableList());

Set<String> result = null;
for (int i = 0; i < selectedIndices.length; i++) {
String indexOrPattern = selectedIndices[i];
for (int i = 0; i < excludesAtEndSelectedIndices.size(); i++) {
String indexOrPattern = excludesAtEndSelectedIndices.get(i);
boolean add = true;
if (!indexOrPattern.isEmpty()) {
if (availableIndices.contains(indexOrPattern)) {
Expand All @@ -89,7 +99,9 @@ public static List<String> filterIndices(List<String> availableIndices, String[]
result = new HashSet<>();
}
} else if (indexOrPattern.charAt(0) == '-') {
// if its the first, fill it with all the indices...
// If the first index pattern is an exclusion, then all patterns are exclusions due to the
// reordering logic above. In this case, the request is interpreted as "include all indexes except
// those matching the exclusions" so we add all indices here and then remove the ones that match the exclusion patterns.
if (i == 0) {
result = new HashSet<>(availableIndices);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public void testIndexNameFiltering() {
assertIndexNameFiltering(new String[] { "foo", "bar", "baz" }, new String[] { "-ba*" }, new String[] { "foo" });
assertIndexNameFiltering(new String[] { "foo", "bar", "baz" }, new String[] { "+ba*" }, new String[] { "bar", "baz" });
assertIndexNameFiltering(new String[] { "foo", "bar", "baz" }, new String[] { "+bar", "+foo" }, new String[] { "bar", "foo" });
assertIndexNameFiltering(new String[] { "foo", "bar", "baz" }, new String[] { "-bar", "b*" }, new String[] { "baz" });
assertIndexNameFiltering(new String[] { "foo", "bar", "baz" }, new String[] { "b*", "-bar" }, new String[] { "baz" });
assertIndexNameFiltering(new String[] { "foo", "bar", "baz" }, new String[] { "-bar", "-baz" }, new String[] { "foo" });
assertIndexNameFiltering(
new String[] { "foo", "bar", "baz" },
new String[] { "zzz", "bar" },
Expand Down

0 comments on commit 0541bbb

Please sign in to comment.