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

Allow message patch version #659

Closed
wants to merge 4 commits into from
Closed

Conversation

haixuanTao
Copy link
Collaborator

Merge after #658

This PR makes dora-message patch version accepted between them, and not fail.

@haixuanTao haixuanTao changed the base branch from main to fix-distributed-node September 18, 2024 15:47
Base automatically changed from fix-distributed-node to main September 19, 2024 17:50
Comment on lines 36 to 37
let current_version = semver::Version::parse(env!("CARGO_PKG_VERSION"))
.map_err(|error| format!("failed to parse current version: {error}"))?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be how we fill the crate_version argument, so we can just it that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Got it thanks!

Comment on lines 38 to 42
let req = semver::VersionReq::parse(&format!(
"~{}.{}.0",
current_version.major, current_version.minor
))
.map_err(|error| format!("failed to set allowing patch version of messages: {error}"))?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you clarify why this is needed? What is the issue/error with the current code?

Copy link
Collaborator Author

@haixuanTao haixuanTao Oct 8, 2024

Choose a reason for hiding this comment

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

Ok, so the current code will fail if we send a patched version message. When we bump dora-message to 4.0.1 it will not pass the semver that is below the current version. So 4.0.1 will not pass 4.0.0. See: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=c5eaa703cadac747d68985cd10faba7a

With VersionReq::parse("~4.0.0"), we allow for all patch version.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The thing is we might want to push updates to messages that are unrelated to the node api. For example adding a new message between the cli and the coordinator or what not, and this will allow us to do this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, actually, double checking on this at: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=c5eaa703cadac747d68985cd10faba7a

It seems the blocking piece is let matches = req.matches(&specified_version) || specified_dora_req.matches(crate_version);

I'm going to replace this piece.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems the blocking piece is let matches = req.matches(&specified_version) || specified_dora_req.matches(crate_version);

I'm a bit confused what the issue of that piece is. We compare in both directions and return true when either one matches.

Given that we're using semver conventions for the message crate, caret requirements seemed like the best match. We can also do tillde requirements if you prefer, this would be a bit stricter. For example, 4.1.0 is semver-compatible with 4.0.0, but not tilde-compatible.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, my bad I confused || with an and sign instead of a or sign.

I guess we can leave is as is in that case

@haixuanTao haixuanTao closed this Oct 9, 2024
@haixuanTao
Copy link
Collaborator Author

Closed as the behviour was actually right.

@LyonRust LyonRust deleted the allow-message-patch-version branch October 13, 2024 08:42
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.

2 participants