Skip to content
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 metadata transformations with metadata tuples #1148

Merged
merged 5 commits into from
Nov 26, 2024

Conversation

AndreKurait
Copy link
Member

@AndreKurait AndreKurait commented Nov 19, 2024

Description

Add metadata transformations with metadata tuples.

Adds SKIPPED migration failure type

  • Category: New feature
  • Why these changes are required? Users may require metadata transformations across versions, particularly to support multi-type indices.
  • What is the old behavior before changes and new behavior after changes? No Metadata tuples, no shown output for skipped indexes/templates, no transformation support in metadata

Issues Resolved

#1115

https://opensearch.atlassian.net/browse/MIGRATIONS-2157

Is this a backport? If so, please add backport PR # and/or commits #

Testing

Unit tests added, aws testing for log format and location

Check List

  • New functionality includes testing
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented
  • Commits are signed per the DCO using --signoff

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.

Copy link

codecov bot commented Nov 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.94%. Comparing base (1c23ab4) to head (18e83bb).
Report is 6 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1148      +/-   ##
============================================
+ Coverage     80.77%   80.94%   +0.16%     
- Complexity     2952     2995      +43     
============================================
  Files           400      407       +7     
  Lines         15111    15229     +118     
  Branches       1021     1023       +2     
============================================
+ Hits          12206    12327     +121     
+ Misses         2287     2273      -14     
- Partials        618      629      +11     
Flag Coverage Δ
unittests 80.94% <ø> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


import lombok.extern.slf4j.Slf4j;

/** Shared functionality between migration and evaluation commands */
@Slf4j
public abstract class MigratorEvaluatorBase {
public static final String NOOP_TRANSFORMATION_CONFIG = "[" +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets remove this, if there is no transformation config why create and use the factory?

Copy link
Member

@chelma chelma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work here! Looking forward to seeing some tests to help understand the user experience a bit better. Overall, feels like a good first step as we continue to iterate and evolve our vision for transformations.

Comment on lines +120 to +125
var transformedTemplates = Stream.concat(Stream.concat(
legacyTemplates.stream(),
indexTemplates.stream()),
componentTemplates.stream()
)
.map(this::transformMigrationItem).collect(Collectors.toList());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why combine all the different migration item types into an undifferentiated stream, transform, then split them up again? Wouldn't it be easier and more efficient to just apply the transform to each class individually?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, we are supporting the case where someone migrates from legacy templates to index templates

Comment on lines +102 to +104
log.atInfo().setMessage("BeforeJsonGlobal: {}").addArgument(() -> printMap(inputJson)).log();
var afterJson = transformer.transformJson(inputJson);
log.atInfo().setMessage("AfterJsonGlobal: {}").addArgument(() -> printMap(afterJson)).log();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's interesting to have a pre-processor transform for the global metadata but not the index settings. Is this an opinionated stance or just a matter of current necessity? Also - how does this fit into the bigger picture we previously discussed of having user-supplied bulk pre/post processing transforms then line-item transforms for each individual MigrationItem between those two steps?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've cleaned this up in the latest version, the unit of transformation for index settings is the entire object, whereas for global metadata it's the sub-object (individual template).

Copy link
Member

@peternied peternied left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tests, looks like maybe there is some kind of refactoring we can do in the future to cleanup the setup / verification that is very similar between the tests, but this gives me a lot of confidence that we will know when we break something - much appreciated.

Seems like there is a one off system index that is causing the new test cases to fail and some style cop changes, but the bones of this good to me once CI is passing.

@AndreKurait AndreKurait merged commit 92f0d3f into opensearch-project:main Nov 26, 2024
21 of 22 checks passed
@AndreKurait AndreKurait deleted the MetadataTransforms branch November 26, 2024 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants