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

refactor: allow all semantic versions #18220

Merged
merged 2 commits into from
May 7, 2024
Merged

refactor: allow all semantic versions #18220

merged 2 commits into from
May 7, 2024

Conversation

npepinpe
Copy link
Member

@npepinpe npepinpe commented May 3, 2024

Description

Modifies the Atomix utility Version to use the more complete SemanticVersion utility from Zeebe. This fully complies with the semantic version spec, and is much more lenient about adding build-metadata and so on.

At the same time, we preserve the check on start up that the version is parse-able at all, to avoid issues where we would run with un-parseable versions and potentially use a snapshot which could cause inconsistencies.

Related issues

related to https://camunda.slack.com/archives/C03NFMH4KC6/p1714730721838389

@npepinpe npepinpe added the backport stable/8.5 Backport a pull request to stable/8.5 label May 3, 2024
@github-actions github-actions bot added the component/zeebe Related to the Zeebe component/team label May 3, 2024
assertThat(Version.from("1.0.0-rc2")).isLessThan(Version.from("1.0.0-rc2.1"));
assertThat(Version.from("1.0.0-rc1")).isGreaterThan(Version.from("1.0.0-beta1"));
assertThat(Version.from("2.0.0-beta1")).isGreaterThan(Version.from("1.0.0"));
assertThat(Version.from("1.0.0-alpha1")).isGreaterThan(Version.from("1.0.0-SNAPSHOT"));
Copy link
Member Author

@npepinpe npepinpe May 3, 2024

Choose a reason for hiding this comment

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

❗ This is counter intuitive for us, but the semantic version spec doesn't really treat snapshot differently. So right now, I would expect 1.0.0-SNAPSHOT to be the "greatest" version always, such that 1.0.0-alpha1 < 1.0.0-SNAPSHOT < 1.0.0, but this is currently not the case (nor specified in the spec). It's a bit of a gotcha, so maybe @oleschoenburg has some opinion here - but I suspect they simply followed the spec 🤷

Note that previously this was reversed. But since we don't really use the Atomix version in general, it doesn't really matter.

Copy link
Member

Choose a reason for hiding this comment

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

Can we have a test with the case -alpha1-rc1

Copy link
Member Author

Choose a reason for hiding this comment

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

💭 It looks likes a lot of changes, but I actually just use an IntelliJ extension which converts AssertJ stuff, so it was pretty much automated :) Highly recommend it

Copy link
Member

Choose a reason for hiding this comment

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

Uh nice !

checkArgument(major >= 0, "major version must be >= 0");
checkArgument(minor >= 0, "minor version must be >= 0");
checkArgument(patch >= 0, "patch version must be >= 0");
private final String metadata;
Copy link
Member Author

Choose a reason for hiding this comment

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

💭 Backwards compatibility is preserved, since we only add a field, which Kryo can deal with - and that field can be null, it's fine.

Copy link
Member

Choose a reason for hiding this comment

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

It is only an issue if an old broker receives a version from an updated broker right? So via topology? 🤔

@npepinpe
Copy link
Member Author

npepinpe commented May 3, 2024

Can't backport prior to 8.5 since we don't have SemanticVersion there :) I can make it more lenient for these versions, but imo we don't do alphas anyway on stable versions, only patches 🤷

Copy link
Member

@Zelldon Zelldon 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 quick fix @npepinpe

I added a small regression test to verify that alpha release candidates are allowed.

Before it fails with:

java.lang.IllegalArgumentException: alpha1-rc1 is not a valid build version string

	at io.atomix.utils.Version$Build.from(Version.java:179)
	at io.atomix.utils.Version.<init>(Version.java:41)
	at io.atomix.utils.Version.from(Version.java:70)
	at io.atomix.utils.VersionTest.shouldAllowAlphaReleaseCandidates(VersionTest.java:34)

With your changes it succeeds 🚀 Cool stuff 🙇🏼

npepinpe and others added 2 commits May 6, 2024 08:56
Modifies the Atomix utility `Version` to use the more complete
`SemanticVersion` utility from Zeebe. This fully complies with the
semantic version spec, and is much more lenient about adding
build-metadata and so on.

At the same time, we preserve the check on start up that the version is
parse-able at all, to avoid issues where we would run with un-parseable
versions and potentially use a snapshot which could cause
inconsistencies.
@Zelldon
Copy link
Member

Zelldon commented May 6, 2024

I had to rebase the branch to main, as it seem we have a new required check for the merge queue.

Zelldon added a commit that referenced this pull request May 6, 2024
## Description

Simple cherry-pick of #18220 

> Description
Modifies the Atomix utili

> ty Version to use the more complete SemanticVersion utility from
Zeebe. This fully complies with the semantic version spec, and is much
more lenient about adding build-metadata and so on.
> 
> At the same time, we preserve the check on start up that the version
is parse-able at all, to avoid issues where we would run with
un-parseable versions and potentially use a snapshot which could cause
inconsistencies.
> 

## Related issues

Backport #18220


> Related issues
> related to
https://camunda.slack.com/archives/C03NFMH4KC6/p1714730721838389
@Zelldon Zelldon added this pull request to the merge queue May 6, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 6, 2024
@Zelldon Zelldon added this pull request to the merge queue May 7, 2024
Merged via the queue into main with commit 8b1be27 May 7, 2024
41 checks passed
@Zelldon Zelldon deleted the np-fix-version branch May 7, 2024 07:25
@backport-action
Copy link
Collaborator

Successfully created backport PR for stable/8.5:

github-merge-queue bot pushed a commit that referenced this pull request May 7, 2024
# Description
Backport of #18220 to `stable/8.5`.

relates to
original author: @npepinpe
@Zelldon Zelldon added the version:8.5.1 Marks an issue as being completely or in parts released in 8.5.1 label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport stable/8.5 Backport a pull request to stable/8.5 component/zeebe Related to the Zeebe component/team version:8.5.1 Marks an issue as being completely or in parts released in 8.5.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants