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

Proposal: Improve Cargo dependency format #199

Closed
4 tasks
wllenyj opened this issue Jul 8, 2022 · 7 comments · Fixed by rust-vmm/vmm-sys-util#166 or #202
Closed
4 tasks

Proposal: Improve Cargo dependency format #199

wllenyj opened this issue Jul 8, 2022 · 7 comments · Fixed by rust-vmm/vmm-sys-util#166 or #202

Comments

@wllenyj
Copy link

wllenyj commented Jul 8, 2022

The crates in rust-vmm use >= comparison-requirements to specify specific dependencies. This places a significant maintenance burden on the user who uses it.

Problem

We use vm-memory as an example because the structure of vm-memory runs through the vmm ecosystem and cannot use two different versions. See version-incompatibility-hazards for reasons.

  1. When I develop a library my-lib 0.1.0, it depends on linux-loader and vm-memory, and linux-loader depends on vm-memory >= 0.6. The version of my-lib that depends on vm-memory requires:
  • If use default Caret requirements, then you can only use the latest 0.8.0, not older versions.
  • Also use >=, Finally, it will also use the latest 0.8.0.
  1. When an incompatible version of vm-memory 0.9.0 is released, it will be a disaster. Since cargo's strategy is to use the greatest version. Then, all libraries that depend on vm-memory >= must be fixed and released a new version. And the previous my-lib 0.1.0 will not work. This break is silent.
  2. If we don't want to do an update. Can lock the old version for binary crates. But for libraries, we need to use some hacks. e.g. cargo update -p vm-memory:0.9.0 --precise 0.8.0. And we have to lock the linux-loader as well. But when my-lib is released, it still can't work.

Solution

According to cargo recommendations:

Use caret requirements for dependencies, such as 1.2.3, for most situations. This ensures that the resolver can be maximally flexible in choosing a version while maintaining build compatibility.

And most open sources also use the SemVer version requirement(x.y.z), which is equivalent to Caret requirements(^x.y.z).
Mentioned in document specifying-dependencies:

It actually specifies a range of versions and allows SemVer compatible updates.
An update is allowed if the new version number does not modify the left-most non-zero digit in the major, minor, patch grouping.

The SemVer version requirement can solve the problems mentioned earlier.

  1. We can specify any version, as they all have a corresponding compatibility range. e.g. linux-loader 0.5.x corresponds to vm-memory 0.9.x, x upgrade does not break compatibility either.
  2. Incompatible versions are released, and will not affect other crates.
  3. If you do not upgrade the dependencies, it will also compile normally.

NOTE:
An incompatible version means the left-most non-zero digit in x.y.z grouping is different.

Drawbacks

  1. When an incompatible version is released, the rust-vmm crate that depends on this crate needs to provide a new version. So that users can choose when they need to upgrade.
  2. When an incompatible version is released, it may be necessary to create a corresponding branch, in order to prepare for a patch release later.
    You can also not create it, then the incompatible version needs to be released immediately after the API incompatible change is merged.

Required Work

  1. Version releases need to be strictly follow SemVer Compatibility to determine API compatibility, and release the corresponding version number.
  2. Modify all rust-vmm crate dependencies to SemVer version requirements. and release a new incompatible version.
  3. [Option] Create branches for incompatible versions.

Progress

image

  • update vmm-sys-util.
  • update vm-memory, kvm-bindings.
  • update linux-loader, virtio-queue, kvm-ioctls.
  • update others.

Thanks.

@andreeaflorescu
Copy link
Member

This proposal sounds sane to me. We can enable dependabot updates for rust-vmm crates as well so that we can merge the dependency updates easier.

CC: @rbradford @sboeuf @bonzini @jiangliu what do you think?

@jiangliu
Copy link
Member

Looks good to me:)

@sboeuf
Copy link

sboeuf commented Jul 18, 2022

Sounds good to me

@slp
Copy link
Contributor

slp commented Jul 18, 2022

I agree that switching to = x.y.z is a good idea, but that would only start fixing our problems once crates start switching from zero versions (0.y.z) to stable versions (1.y.z), as otherwise each increase of y would mean an incompatible version. I think vm-memory and vmm-sys-util are good candidates for becoming stable.

I've started packaging rust-vmm components in Fedora, and dealing with 0.y.z versions is making it really painful.

@wllenyj
Copy link
Author

wllenyj commented Jul 22, 2022

but that would only start fixing our problems once crates start switching from zero versions (0.y.z) to stable versions (1.y.z)

Mentioned in semver-compatibility:

Versions are considered compatible if their left-most non-zero major/minor/patch component is the same. 
For example, 1.0.3 and 1.1.0 are considered compatible, and thus it should be safe to update from 
the older release to the newer one. However, an update from 1.1.0 to 2.0.0 would not be allowed to 
be made automatically. This convention also applies to versions with leading zeros. For example, 
0.1.0 and 0.1.2 are compatible, but 0.1.0 and 0.2.0 are not. Similarly, 0.0.1 and 0.0.2 are not compatible.

So we can increase y in the 0.y.z for incompatible version, otherwise increase z for bugfix version.
and also increase x in the x.y.z for incompatible version, otherwise increase y or z for bugfix version.

@andreeaflorescu
Copy link
Member

So we can increase y in the 0.y.z for incompatible version, otherwise increase z for bugfix version. and also increase x in the x.y.z for incompatible version, otherwise increase y or z for bugfix version.

This is our current strategy. This is why your proposal for using caret dependencies works even for crates that are not at a major version. I think we can separate the discussions:

  1. Use your proposal for crates that are at 0.x.y. @wllenyj can you open a PR so we can merge this proposal? Just to clarify, the proposal is not to use =0.x.y, but ^0.x.y which means that crates update automatically to newer patch versions, but don't update to minor versions which might have compatibility issues.
  2. Discuss about moving to 1 for crates that are stable. @slp do you want to open an issue in the repositories where you think that should be the case?

wllenyj added a commit to wllenyj/vmm-sys-util that referenced this issue Jul 22, 2022
andreeaflorescu added a commit to andreeaflorescu/vm-virtio that referenced this issue Jul 25, 2022
We should use caret requirements for crates that are not yet on
a major release. This helps with avoiding breaking changes
because for any crate specified as 0.x.y, when a new release
is available, cargo will only pick up new patch releases.

Related issues:
- rust-vmm/vm-memory#199
- rust-vmm/community#131

Signed-off-by: Andreea Florescu <[email protected]>
wllenyj added a commit to wllenyj/dragonball-sandbox that referenced this issue Jul 25, 2022
Due to the release of vmm-sys-util version 0.10.0 there are multiple
vmm-sys-util dependencies.

This will be resolved in
rust-vmm/vm-memory#199.

Signed-off-by: wllenyj <[email protected]>
wllenyj added a commit to wllenyj/dragonball-sandbox that referenced this issue Jul 25, 2022
Due to the release of vmm-sys-util version 0.10.0 there are multiple
vmm-sys-util dependencies.

This will be resolved in
rust-vmm/vm-memory#199.

Signed-off-by: wllenyj <[email protected]>
wllenyj added a commit to wllenyj/dragonball-sandbox that referenced this issue Jul 25, 2022
Due to the release of vmm-sys-util version 0.10.0 there are multiple
vmm-sys-util dependencies.

This will be resolved in
rust-vmm/vm-memory#199.

Signed-off-by: wllenyj <[email protected]>
wllenyj added a commit to wllenyj/dragonball-sandbox that referenced this issue Jul 25, 2022
Due to the release of vmm-sys-util version 0.10.0 there are multiple
vmm-sys-util dependencies.

This will be resolved in
rust-vmm/vm-memory#199.

Signed-off-by: wllenyj <[email protected]>
wllenyj added a commit to wllenyj/dragonball-sandbox that referenced this issue Jul 25, 2022
Due to the release of vmm-sys-util version 0.10.0 there are multiple
vmm-sys-util dependencies.

This will be resolved in
rust-vmm/vm-memory#199.

Signed-off-by: wllenyj <[email protected]>
wllenyj added a commit to wllenyj/dragonball-sandbox that referenced this issue Jul 25, 2022
Due to the release of vmm-sys-util version 0.10.0 there are multiple
vmm-sys-util dependencies.

This will be resolved in
rust-vmm/vm-memory#199.

Signed-off-by: wllenyj <[email protected]>
wllenyj added a commit to wllenyj/dragonball-sandbox that referenced this issue Jul 25, 2022
Due to the release of vmm-sys-util version 0.10.0 there are multiple
vmm-sys-util dependencies.

This will be resolved in
rust-vmm/vm-memory#199.

Signed-off-by: wllenyj <[email protected]>
studychao pushed a commit to openanolis/dragonball-sandbox that referenced this issue Jul 26, 2022
Due to the release of vmm-sys-util version 0.10.0 there are multiple
vmm-sys-util dependencies.

This will be resolved in
rust-vmm/vm-memory#199.

Signed-off-by: wllenyj <[email protected]>
jiangliu pushed a commit to rust-vmm/vm-virtio that referenced this issue Jul 26, 2022
We should use caret requirements for crates that are not yet on
a major release. This helps with avoiding breaking changes
because for any crate specified as 0.x.y, when a new release
is available, cargo will only pick up new patch releases.

Related issues:
- rust-vmm/vm-memory#199
- rust-vmm/community#131

Signed-off-by: Andreea Florescu <[email protected]>
lauralt pushed a commit to rust-vmm/vmm-sys-util that referenced this issue Jul 27, 2022
@andreeaflorescu
Copy link
Member

This is not fixed for vm-memory, re-opening the issue.

lauralt added a commit to lauralt/vm-memory that referenced this issue Aug 12, 2022
This way the deps that are below 1.0 will only be updated
at the patch level, and the ones >= 1.0, at the patch and
minor levels.
Fixes: rust-vmm#199.
Also updated vmm-sys-util to latest version available.

Signed-off-by: Laura Loghin <[email protected]>
lauralt added a commit to lauralt/vm-memory that referenced this issue Aug 16, 2022
This way the deps that are below 1.0 will only be updated
at the patch level, and the ones >= 1.0, at the patch and
minor levels.
Fixes: rust-vmm#199.
Also updated vmm-sys-util to latest version available.

Signed-off-by: Laura Loghin <[email protected]>
andreeaflorescu pushed a commit that referenced this issue Aug 16, 2022
This way the deps that are below 1.0 will only be updated
at the patch level, and the ones >= 1.0, at the patch and
minor levels.
Fixes: #199.
Also updated vmm-sys-util to latest version available.

Signed-off-by: Laura Loghin <[email protected]>
studychao added a commit to openanolis/kata-containers that referenced this issue Nov 14, 2022
Since the upstream rust-vmm is changing its dependency style towards
caret requirements in these days (more information:
rust-vmm/vm-memory#199) and it breaks Dragonball compilation frequently.

rust-vmm is expected to finish the changes this week and in order to not
break Kata CI due to Dragonball's compilation error, we will add
Cargo.lock file into /src/dragonball first and remove it later when
rust-vmm is stable.

fixes: kata-containers#5657

Signed-off-by: Chao Wu <[email protected]>
studychao added a commit to openanolis/kata-containers that referenced this issue Nov 16, 2022
Since the upstream rust-vmm is changing its dependency style towards
caret requirements in these days (more information:
rust-vmm/vm-memory#199) and it breaks Dragonball compilation frequently.

rust-vmm is expected to finish the changes this week and in order to not
break Kata CI due to Dragonball's compilation error, we will add
Cargo.lock file into /src/dragonball first and remove it later when
rust-vmm is stable.

fixes: kata-containers#5657
Depends-on: kata-containers#5640
Signed-off-by: Chao Wu <[email protected]>
fidencio pushed a commit to fidencio/kata-containers that referenced this issue Nov 16, 2022
Since the upstream rust-vmm is changing its dependency style towards
caret requirements in these days (more information:
rust-vmm/vm-memory#199) and it breaks Dragonball compilation frequently.

rust-vmm is expected to finish the changes this week and in order to not
break Kata CI due to Dragonball's compilation error, we will add
Cargo.lock file into /src/dragonball first and remove it later when
rust-vmm is stable.

fixes: kata-containers#5657
Signed-off-by: Chao Wu <[email protected]>
studychao added a commit to openanolis/kata-containers that referenced this issue Nov 16, 2022
Since the upstream rust-vmm is changing its dependency style towards
caret requirements in these days (more information:
rust-vmm/vm-memory#199) and it breaks Dragonball compilation frequently.

rust-vmm is expected to finish the changes this week and in order to not
break Kata CI due to Dragonball's compilation error, we will add
Cargo.lock file into /src/dragonball first and remove it later when
rust-vmm is stable.

fixes: kata-containers#5657
Depends-on: github.com/kata-containers#5640

Signed-off-by: Chao Wu <[email protected]>
DabinJang96 pushed a commit to DabinJang96/kata-containers that referenced this issue Dec 6, 2022
Since the upstream rust-vmm is changing its dependency style towards
caret requirements in these days (more information:
rust-vmm/vm-memory#199) and it breaks Dragonball compilation frequently.

rust-vmm is expected to finish the changes this week and in order to not
break Kata CI due to Dragonball's compilation error, we will add
Cargo.lock file into /src/dragonball first and remove it later when
rust-vmm is stable.

fixes: kata-containers#5657
Signed-off-by: Chao Wu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants