-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add new "semver" constraint #6699
Conversation
@schmichael Is it not just a bug in |
This comment gives more details: hashicorp/go-version#36 (comment) I guess for Terraform this makes... sense? I worry that the two constraints are so nearly identical it will be confusing to have both. Did you talk to James Bardin to see if removing the prerelease constraints is something they'd be willing to do or if it is a hard requirement for Terraform? |
Yes, that was the internal consensus. The current go-version behavior is modelled after npm where if you have a constraint of ">= 1.0" and the package is at "1.1-beta1", you'd rather download "1.0" than use a prerelease. Nomad and other non-package-manager use cases just don't have the luxury of being able to download an artifact to satisfy missing constraints, so it's a different situation. Likewise I completely dropped the
Indeed. I just didn't see an alternative. Nomad doesn't even define the behavior of
Yup, and Martin on the Terraform team. Martin wasn't too excited about me calling it "semver" because technically semver only covers ordering/precedence, and does not explicitly cover constraints semantics. I chose it anyway because (a) I couldn't think of another name that was less confusing and (b) reading the semver spec is sufficient to understand the operator's behavior. |
scheduler/feasible.go
Outdated
@@ -601,7 +606,7 @@ func checkLexicalOrder(op string, lVal, rVal interface{}) bool { | |||
|
|||
// checkVersionMatch is used to compare a version on the | |||
// left hand side with a set of constraints on the right hand side | |||
func checkVersionMatch(ctx Context, lVal, rVal interface{}) bool { | |||
func checkVersionMatch(ctx Context, parse VerConstraintParser, lVal, rVal interface{}) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love how DRY you made this 🎉
@schmichael Looking really good. Feel free to ping when you want the final review (its still marked draft so I assume you have some more changes?) |
3d4182c
to
4e84a43
Compare
The existing version constraint uses logic optimized for package managers, not schedulers, when checking prereleases: - 1.3.0-beta1 will *not* satisfy ">= 0.6.1" - 1.7.0-rc1 will *not* satisfy ">= 1.6.0-beta1" This is due to package managers wishing to favor final releases over prereleases. In a scheduler versions more often represent the earliest release all required features/APIs are available in a system. Whether the constraint or the version being evaluated are prereleases has no impact on ordering. This commit adds a new constraint - `semver` - which will use Semver v2.0 ordering when evaluating constraints. Given the above examples: - 1.3.0-beta1 satisfies ">= 0.6.1" using `semver` - 1.7.0-rc1 satisfies ">= 1.6.0-beta1" using `semver` Since existing jobspecs may rely on the old behavior, a new constraint was added and the implicit Consul Connect and Vault constraints were updated to use it.
4e84a43
to
75d6d4e
Compare
@dadgar Ready for final review. Rebased on master, squashed commits, added docs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Going to merge to get the 0.10.2-rc1 train rolling, but there's still time to address any feedback you might have in a followup @dadgar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
The existing version constraint uses logic optimized for package
managers, not schedulers, when checking prereleases:
This is due to package managers wishing to favor final releases over
prereleases.
In a scheduler versions more often represent the earliest release all
required features/APIs are available in a system. Whether the constraint
or the version being evaluated are prereleases has no impact on
ordering.
This commit adds a new constraint -
semver
- which will use Semverv2.0 ordering when evaluating constraints. Given the above examples:
semver
semver
Since existing jobspecs may rely on the old behavior, a new constraint
was added and the implicit Consul Connect and Vault constraints were
updated to use it.