796758b8a5
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.
31 lines
815 B
Go
31 lines
815 B
Go
package api
|
|
|
|
const (
|
|
ConstraintDistinctProperty = "distinct_property"
|
|
ConstraintDistinctHosts = "distinct_hosts"
|
|
ConstraintRegex = "regexp"
|
|
ConstraintVersion = "version"
|
|
ConstraintSemver = "semver"
|
|
ConstraintSetContains = "set_contains"
|
|
ConstraintSetContainsAll = "set_contains_all"
|
|
ConstraintSetContainsAny = "set_contains_any"
|
|
ConstraintAttributeIsSet = "is_set"
|
|
ConstraintAttributeIsNotSet = "is_not_set"
|
|
)
|
|
|
|
// Constraint is used to serialize a job placement constraint.
|
|
type Constraint struct {
|
|
LTarget string
|
|
RTarget string
|
|
Operand string
|
|
}
|
|
|
|
// NewConstraint generates a new job placement constraint.
|
|
func NewConstraint(left, operand, right string) *Constraint {
|
|
return &Constraint{
|
|
LTarget: left,
|
|
RTarget: right,
|
|
Operand: operand,
|
|
}
|
|
}
|