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

fix: support version compatibility check for pre-release versions #2069

Merged
merged 16 commits into from
Sep 19, 2024

Conversation

KeranYang
Copy link
Member

@KeranYang KeranYang commented Sep 17, 2024

TODO - once this PR gets approved, I will update the minNumaflowVersion in each SDK to add more guidelines on what version string to choose.

closes #2064

.
Signed-off-by: Keran Yang <[email protected]>
@KeranYang KeranYang changed the title fix: version compatibility check issue (WIP) fix: version compatibility check issue Sep 17, 2024
Copy link

codecov bot commented Sep 17, 2024

Codecov Report

Attention: Patch coverage is 97.60479% with 8 lines in your changes missing coverage. Please review.

Project coverage is 63.96%. Comparing base (6914341) to head (7d477ce).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
rust/monovertex/src/server_info.rs 98.13% 6 Missing ⚠️
pkg/sdkclient/serverinfo/types.go 75.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2069      +/-   ##
==========================================
+ Coverage   63.68%   63.96%   +0.28%     
==========================================
  Files         320      321       +1     
  Lines       29345    29572     +227     
==========================================
+ Hits        18687    18916     +229     
+ Misses       9641     9637       -4     
- Partials     1017     1019       +2     

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

Signed-off-by: Keran Yang <[email protected]>
.
Signed-off-by: Keran Yang <[email protected]>
@KeranYang KeranYang changed the title (WIP) fix: version compatibility check issue fix: version compatibility check issue Sep 17, 2024
@KeranYang KeranYang marked this pull request as ready for review September 17, 2024 23:27
@kohlisid
Copy link
Contributor

Hey @KeranYang
Thanks for making these changes! :D
Have you tested if we would we need similar changes in the Monovertex versioning as well? If yes, We can create an issue for that and do in a follow up PR.

@KeranYang
Copy link
Member Author

@kohlisid thank you. I will make similar changes to mono vertex using this PR. Please stay tuned for new commits.

@KeranYang KeranYang marked this pull request as draft September 18, 2024 18:25
@KeranYang KeranYang changed the title fix: version compatibility check issue (WIP) fix: version compatibility check issue Sep 18, 2024
@KeranYang KeranYang changed the title (WIP) fix: version compatibility check issue fix: version compatibility check issue Sep 18, 2024
@KeranYang KeranYang changed the title fix: version compatibility check issue fix: support version compatibility check for pre-release versions Sep 18, 2024
@KeranYang KeranYang marked this pull request as ready for review September 18, 2024 23:46
.
Signed-off-by: Keran Yang <[email protected]>
Copy link
Member

@vigith vigith left a comment

Choose a reason for hiding this comment

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

please do no use unwrap, it is like panic. use map_error instead and convert to Result, then short-circuit the return using ?.

@@ -79,6 +79,39 @@ pub async fn check_for_server_compatibility(

/// Checks if the given version meets the specified constraint.
fn check_constraint(version: &Version, constraint: &str) -> error::Result<()> {
let binding = version.to_string();
// extract the major.minor.patch version
let mmp_version = binding.split('-').next().unwrap();
Copy link
Member

@vigith vigith Sep 19, 2024

Choose a reason for hiding this comment

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

what if there is no -?

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 returns the original string itself.

Signed-off-by: Keran Yang <[email protected]>
Signed-off-by: Keran Yang <[email protected]>
@KeranYang
Copy link
Member Author

KeranYang commented Sep 19, 2024

@kohlisid monovertex change added, please review. Thanks!

.map_err(|e| Error::ServerInfoError(format!("Error parsing Numaflow version: {}", e)))?;

// Create a version constraint based on the minimum numaflow version
let numaflow_constraint = format!(">={}", min_numaflow_version);
check_constraint(&numaflow_version_semver, &numaflow_constraint).map_err(|e| {
Error::ServerInfoError(format!(
"numaflow version {} must be upgraded to at least {}, in order to work with current SDK version {}",
numaflow_version_semver, min_numaflow_version, e
numaflow_version_semver, human_readable(min_numaflow_version.to_string()), e
Copy link
Member

Choose a reason for hiding this comment

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

why are you calling to_string()? just implement Debug for Version via NewType.

Copy link
Member Author

Choose a reason for hiding this comment

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

@vigith , thanks for introducing to me the Debug trait. After learning a bit of it, I would like to keep my change as it is. My use case is to convert the version string used by constraint to a human-readable string. I don't want users to see "please update numaflow to 1.3.1-z", which is confusing, I want them to see "1-3-1".

This is a very simple string conversion. Using Debug will require me to create a new type which wraps a string and create object of that struct during compatibility check, which is extra code. Please let me know if my understanding is off.

Copy link
Member

Choose a reason for hiding this comment

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

isn't "human-readable string" all about Debug Trait is?

Copy link
Member Author

Choose a reason for hiding this comment

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

As discussed offline, I created a separate issue to track. #2076

// e.g., if the given version is "0.8.0rc100", human-readable version is "0.8.0".
// if the given version is "0.8.0-z", "0.8.0".
// if "0.8.0-rc1", "0.8.0-rc1".
fn human_readable(ver: String) -> String {
Copy link
Member

Choose a reason for hiding this comment

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

impl Debug via the above asked NewType?

"0.8.0b1", "0.8.0b1" for python.
2. The minimum supported version is a stable version.
In this case, put (almost) the largest available pre-release version of the stable version in the map.
E.g., if the minimum supported version is "0.8.0", then put "0.8.0-z" for java, go, rust, "0.8.0rc100" for python.
Copy link
Member

Choose a reason for hiding this comment

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

Curious, why using -z?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it's mainly because of the golang semver library "considering pre-releases to be invalid if the ranges does not include one". So we have to put a pre-release version in the constraint. To do so, we need to put the largest pre-release, hence -z and rc100 for python.

I will improve the docs accordingly.

.
Signed-off-by: Keran Yang <[email protected]>
.
Signed-off-by: Keran Yang <[email protected]>
@KeranYang KeranYang merged commit ed543ad into numaproj:main Sep 19, 2024
25 checks passed
@KeranYang KeranYang deleted the vcc branch September 19, 2024 21:06
whynowy pushed a commit that referenced this pull request Sep 26, 2024
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.

SDK version compatibility check fails for pre-releases
4 participants