-
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
Distinct Property supports arbitrary limit #2942
Conversation
This PR enhances the distinct_property constraint such that a limit can be specified in the RTarget/value parameter. This allows constraints such as: ``` constraint { distinct_property = "${meta.rack}" value = "2" } ``` This restricts any given rack from running more than 2 allocations from the task group. Fixes #1146
scheduler/propertyset.go
Outdated
p.populateExisting(constraint) | ||
|
||
// Populate the proposed when setting the constraint. We do this because | ||
// when detecting if we can inplace update an allocation we stage an | ||
// eviction and then select. This means the plan has an eviction before a | ||
// single select has finished. | ||
p.PopulateProposed() | ||
|
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.
nit: remove
scheduler/propertyset.go
Outdated
continue | ||
} | ||
|
||
return false, fmt.Sprintf("distinct_property: %s=%s already used", p.constraint.LTarget, nValue) | ||
// Don't clear below 0. | ||
combinedUse[propertyValue] = helper.Uint64Max(0, combined-clearedCount) |
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.
Since you're using uint if combined < clearedCount
, the value will wrap and be extremely large instead of getting clamped to 0.
I think this should be:
if combined >= clearedCount {
combinedUse[propertyValue] = combined-clearedCount
} else {
combinedUse[propertyValue] = 0
}
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.
Good catch!
Will this allow me to run a system job, and say "but only 3 allocations per AWS AZ" ? |
@jippi System job is really intended to run on all machines, so it is somewhat abusive. I would do one of two things:
|
I think this commit was the last piece to get similar functionality as this PR #2168 |
@dropje86 Sorry they are actually slightly different as this is a limit and that is a balance. |
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. |
This PR enhances the distinct_property constraint such that a limit can be
specified in the RTarget/value parameter. This allows constraints such as:
This restricts any given rack from running more than 2 allocations from the
task group.
This PR also adds better validation of the constraints.
Fixes #1146