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

[Versioning] Fix Version.fromString logic for legacy version #604

Merged

Conversation

nknize
Copy link
Collaborator

@nknize nknize commented Apr 22, 2021

Description

This PR fixes the Version.fromString logic to identify legacy versions. It
also adds an optional "distribution" field to the MainRespose for OpenSearch
version 1.0.0+. Any preceeding versions that do not contain the distribution
label will be handeled as legacy versions appropriately. This is tested in
remote reindex integration tests.

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • 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.

This commit fixes the Version.fromString logic to identify legacy versions. It
also adds an optional "distribution" field to the MainRespose for OpenSearch
version 1.0.0+. Any preceeding versions that do not contain the distribution
label will be handeled as legacy versions appropriately.

Signed-off-by: Nicholas Walter Knize <[email protected]>
@nknize nknize added Re-version All issues associated with rebasing the opensearch version off 1.0.0 v1.0.0 Version 1.0.0 v1.0.0-alpha1 Version 1.0.0 alpha 1 v2.0.0 Version 2.0.0 labels Apr 22, 2021
@odfe-release-bot
Copy link

✅   Gradle Wrapper Validation success c52f74f

@nknize
Copy link
Collaborator Author

nknize commented Apr 22, 2021

start gradle check

@odfe-release-bot
Copy link

✅   DCO Check Passed c52f74f

@odfe-release-bot
Copy link

✅   Gradle Precommit success c52f74f

@odfe-release-bot
Copy link

✅   Gradle Check success c52f74f
Log 126

Reports 126

@CEHENKLE
Copy link
Member

This is awesome Nick!

Copy link
Contributor

@adnapibar adnapibar left a comment

Choose a reason for hiding this comment

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

👍 Some minor comments. I feel we need to refactor (in subsequent iterations) the Version and LegacyESVersion a bit to make them cleaner.

server/src/main/java/org/opensearch/Version.java Outdated Show resolved Hide resolved
server/src/main/java/org/opensearch/Version.java Outdated Show resolved Hide resolved
server/src/main/java/org/opensearch/Version.java Outdated Show resolved Hide resolved
Comment on lines +145 to +147
protected static final ImmutableOpenIntMap<Version> idToVersion;
protected static final ImmutableOpenMap<String, Version> stringToVersion;
static {
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason behind moving the code to here?
I think we can refactor this to a separate class e.g. VersionCache or CachedVersions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

classloader race condition. The static block requires fields of LegacyESVersion to be non-null but Version is loaded before LegacyESVersion since LegacyESVersion inherits from Version.

Copy link
Member

@dblock dblock Apr 23, 2021

Choose a reason for hiding this comment

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

Thanks for the explanation. PRed #608 that may have made this easier to catch.

/**
* Returns the version given its string representation, current version if the argument is null or empty
*/
public static Version fromString(String version) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like this inherited from Version.java, duplicated?

Copy link
Collaborator Author

@nknize nknize Apr 23, 2021

Choose a reason for hiding this comment

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

No.. it's a static method that needs to call the LegacyESVersion.fromStringSlow so it needs to be overloaded here. If inherited it will call the wrong implementation. (This is part of the hacky-ness that needs to be reworked over time).

@nknize
Copy link
Collaborator Author

nknize commented Apr 23, 2021

Agree there's some more cleanup needed; and we probably want to add back support to Version for RC build tags. Let's take care of those in followup PRs.

Signed-off-by: Nicholas Walter Knize <[email protected]>
@nknize
Copy link
Collaborator Author

nknize commented Apr 23, 2021

start gradle check

@odfe-release-bot
Copy link

✅   DCO Check Passed 2c37340

@odfe-release-bot
Copy link

✅   Gradle Wrapper Validation success 2c37340

@odfe-release-bot
Copy link

✅   Gradle Precommit success 2c37340

@odfe-release-bot
Copy link

✅   Gradle Check success 2c37340
Log 128

Reports 128

@nknize nknize merged commit 6e04778 into opensearch-project:main Apr 23, 2021
ritty27 pushed a commit to ritty27/OpenSearch that referenced this pull request May 12, 2024
* Added "cjk" analyzer.

Signed-off-by: pieper <[email protected]>

* Adapted changelog.

Signed-off-by: pieper <[email protected]>

* Fixed license headers.

Signed-off-by: pieper <[email protected]>

* Tab vs. Spaces fix.

Signed-off-by: pieper <[email protected]>

---------

Signed-off-by: pieper <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Re-version All issues associated with rebasing the opensearch version off 1.0.0 v1.0.0-alpha1 Version 1.0.0 alpha 1 v1.0.0 Version 1.0.0 v2.0.0 Version 2.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants