opensearch-project / opensearch-migrations

Migrate, upgrade, compare, and replicate OpenSearch clusters with ease.
https://aws.amazon.com/solutions/implementations/migration-assistant-for-amazon-opensearch-service/
Apache License 2.0
39 stars 28 forks source link

Auto detect target cluster version #1118

Closed peternied closed 2 weeks ago

peternied commented 2 weeks ago

Description

Adding automatic version detection that supports both flavors of the Amazon Managed OpenSearch and Serverless offerings. Also detecting if combability mode has been enabled that will extract the version number from the _cat/plugins api, specifically looking at the repository-s3 plugin.

Issues Resolved

Testing

Tested with both a managed and serverless cluster locally.

> ./gradlew MetadataMigration:run --args='evaluate --source-host https://search-target-domain-p5keoxlvhl5slkqgildik64mce.us-west-2.es.amazonaws.com/ --source-aws-region us-west-2 --source-aws-service-signing-name es --target-host https://vwpt0d13nhrsiinwng90.us-west-2.aoss.amazonaws.com/ --target-aws-region us-west-2 --target-aws-service-signing-name aoss'

> Task :MetadataMigration:run
Starting Metadata Evaluation
Clusters:
   Source:
      Remote Cluster: AMAZON_MANAGED_OPENSEARCH 2.13.0 ConnectionContext(uri=https://search-target-domain-p5keoxlvhl5slkqgildik64mce.us-west-2.es.amazonaws.com/, protocol=HTTPS, insecure=false, compressionSupported=false, awsSpecificAuthentication=true)

   Target:
      Remote Cluster: AMAZON_SERVERLESS_OPENSEARCH 2.0.0 ConnectionContext(uri=https://vwpt0d13nhrsiinwng90.us-west-2.aoss.amazonaws.com/, protocol=HTTPS, insecure=false, compressionSupported=false, awsSpecificAuthentication=true)

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.

codecov[bot] commented 2 weeks ago

Codecov Report

Attention: Patch coverage is 77.01149% with 20 lines in your changes missing coverage. Please review.

Project coverage is 80.55%. Comparing base (48da9ce) to head (754e316). Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...h/migrations/bulkload/common/OpenSearchClient.java 73.91% 11 Missing and 7 partials :warning:
...ava/org/opensearch/migrations/VersionMatchers.java 75.00% 1 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1118 +/- ## ============================================ + Coverage 80.51% 80.55% +0.03% - Complexity 2871 2908 +37 ============================================ Files 393 393 Lines 14554 14630 +76 Branches 1000 1007 +7 ============================================ + Hits 11718 11785 +67 - Misses 2229 2232 +3 - Partials 607 613 +6 ``` | [Flag](https://app.codecov.io/gh/opensearch-project/opensearch-migrations/pull/1118/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensearch-project) | Coverage Δ | | |---|---|---| | [gradle-test](https://app.codecov.io/gh/opensearch-project/opensearch-migrations/pull/1118/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensearch-project) | `78.66% <77.01%> (+0.05%)` | :arrow_up: | | [python-test](https://app.codecov.io/gh/opensearch-project/opensearch-migrations/pull/1118/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensearch-project) | `90.33% <ø> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensearch-project#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

peternied commented 2 weeks ago

@gregschohn Thanks for the great suggestion, the nodes API is much more trust worthy IMO. I've swapped out the plugins api for it, it was a relatively simple change.

For reusing this code elsewhere, I think we have a complicated story about how that can work today. I'd prefer to move forward with this implementation and we can figure out how and where to make this logic available in other parts of the migration ecosystem and what the best way to do that is.

chelma commented 2 weeks ago

We'll need this functionality (very soon) to determine how to transform metadata from a source version to a target version, right? That problem isn't constrained to just one java program. It isn't even just constrained to our suite of java programs.

+1, makes sense. I'm sure we'll be revisiting this soon.

I'd prefer to move forward with this implementation and we can figure out how and where to make this logic available in other parts of the migration ecosystem

That makes sense to me, thanks for the work on this @peternied . Thanks also to @gregschohn for the suggestion on the Nodes API, it alleviates a lot of my concern about brittleness.