-
Notifications
You must be signed in to change notification settings - Fork 30
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
Add indexAllowlist to snapshot create command #1009
Add indexAllowlist to snapshot create command #1009
Conversation
Signed-off-by: Mikayla Thompson <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1009 +/- ##
============================================
+ Coverage 80.22% 80.46% +0.24%
- Complexity 2721 2734 +13
============================================
Files 365 365
Lines 13595 13624 +29
Branches 939 942 +3
============================================
+ Hits 10906 10962 +56
+ Misses 2118 2084 -34
- Partials 571 578 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: Mikayla Thompson <[email protected]>
5ac0352
to
4eb8674
Compare
Signed-off-by: Mikayla Thompson <[email protected]>
Signed-off-by: Mikayla Thompson <[email protected]>
final FullHttpRequest[] createSnapshotRequest = new FullHttpRequest[1]; | ||
final String[] createSnapshotRequestContent = {""}; |
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.
These arrays were IntelliJ's suggestion to fix the issue that you can't use a non-final in a lambda. Open to a better suggestion if this is not the right way to resolve 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.
Yeah - sorry. This is a java-ism. It makes me realize why the capture specifiers in C++ [=foo,&bar]
really aren't that bad!
You can also do an AtomicReference/AtomicInteger, etc. I usually do the AtomicReference thing because it seems more clear to me. Our codebase isn't to the level of consistency where it matters, especially for test cases!
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.
an AtomicReference/AtomicString would make more sense 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.
Okay, cool, thanks -- updated this to AtomicReferences
Signed-off-by: Mikayla Thompson <[email protected]>
@@ -59,6 +61,10 @@ public static class Args { | |||
"--s3-role-arn" }, required = false, description = "The role ARN the cluster will assume to write a snapshot to S3") | |||
public String s3RoleArn; | |||
|
|||
@Parameter(names = { | |||
"--index-allowlist" }, required = false, description = "A comma separated list of indices to include in the snapshot. If not provided, all indices are included.") |
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.
Do we want to align this with document migration which excludes system indicies by default
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 lean towards including them by default. I'm fine with not transferring them by default, but if a user ends up wanting to move some/all of them, it would be very annoying to discover that the snapshot didn't include them.
@Parameter(names = { | ||
"--index-allowlist" }, required = false, description = "A comma separated list of indices to include in the snapshot. If not provided, all indices are included.") |
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.
nit: It would be nice for this to be can you format these to put each annotation parameter its own line (like what's done for CaptureProxy & TrafficReplayer). Like this
@Parameter(
required = false,
names = {"--insecure" },
arity = 0, description = "Do not check the server's certificate")
boolean allowInsecureConnections;
final FullHttpRequest[] createSnapshotRequest = new FullHttpRequest[1]; | ||
final String[] createSnapshotRequestContent = {""}; |
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.
Yeah - sorry. This is a java-ism. It makes me realize why the capture specifiers in C++ [=foo,&bar]
really aren't that bad!
You can also do an AtomicReference/AtomicInteger, etc. I usually do the AtomicReference thing because it seems more clear to me. Our codebase isn't to the level of consistency where it matters, especially for test cases!
assert registerRepoRequest.uri().equals("/_snapshot/migration_assistant_repo"); | ||
assert registerRepoRequest.method().toString().equals("PUT"); | ||
assert registerRepoRequestContent.equals("{\"type\":\"s3\",\"settings\":{\"bucket\":\"new-bucket\",\"region\":\"us-east-2\",\"base_path\":null}}"); | ||
assert createSnapshotRequest.uri().equals("/_snapshot/migration_assistant_repo/" + snapshotName); | ||
assert createSnapshotRequest.method().toString().equals("PUT"); | ||
assert createSnapshotRequestContent.equals("{\"indices\":\"_all\",\"ignore_unavailable\":true,\"include_global_state\":true}"); |
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.
these are java language assertions. If the unit tests were run w/out -ea, these wouldn't be evaluated. If one fails, we probably won't always get the same support that we get in all of our tools to give more hints about what the issues were.
Import Assertions and use Assertions.assertEquals(EXPECTED, ACTUAL, OPTIONAL_AND_RARELY_USED_MESSAGE)
and the other many helpers w/in the Assertions class. Just find "Assertions." for many examples.
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 so much better!
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.apache.commons.lang3.tuple.Pair; |
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 a bit risky since you're (I think) depending on a transitive dependency.
For a test case, it's reasonable to take on extra dependencies that you normally wouldn't want to take on.
That said, the lack of a Pair<> type is well-known for Java devs. Normally, we just do Map.Entry<> for the type and instantiate new AbstractMap.SimpleEntry<>(V1, V2)
. For test code, I'm fine w/ another dependency on this or vavr.io or whatever, it will probably eventually be refactored away to keep dependency graphs smaller.
|
||
assert registerRepoRequest.uri().equals("/_snapshot/migration_assistant_repo"); | ||
assert registerRepoRequest.method().toString().equals("PUT"); | ||
assert registerRepoRequestContent.equals("{\"type\":\"s3\",\"settings\":{\"bucket\":\"new-bucket\",\"region\":\"us-east-2\",\"base_path\":null}}"); |
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.
is base_path = null right?
You might want to normalize the json in the test and from the java class so that if one pretty-prints, you aren't in trouble with a difference.
hamcrest lets you do fancy deep mappings too - but it's another thing to learn and therefore has been a barrier to entry for me (others use it a lot)
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 like the indenting job that you did. Thanks
Signed-off-by: Mikayla Thompson <[email protected]>
Signed-off-by: Mikayla Thompson <[email protected]>
import static org.hamcrest.CoreMatchers.containsString; | ||
import static org.hamcrest.MatcherAssert.assertThat; |
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.
nit: I hate all static imports (others disagree though).
7ba296e
into
opensearch-project:main
Description
Add an
--index-allowlist
flag to theCreateSnapshot
command, which passes the list of fields to the snapshot creation api call.Issues Resolved
[List any issues this PR will resolve]
Is this a backport? If so, please add backport PR # and/or commits #
Testing
Snapshot tests added.
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.