-
Notifications
You must be signed in to change notification settings - Fork 616
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
Use Service Placement Constraints in Enforcer #2857
Conversation
This patch updates the ConstraintEnforcer to use the placement constraints from the current service spec rather than the placement constraints from the current task spec because they may be outdated in some cases (e.g., when the service was previously updated to modify placement constrainst but the node to which the task was scheduled still satisfies the constraints. If the node is updated in a way which causes it to no longer satisfy the new constraints then the task should be removed even if it still would satisfy the original task constraints). Docker-DCO-1.1-Signed-off-by: Josh Hawn <[email protected]> (github: jlhawn)
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.
// original and outdated constraints (that are still satisfied by | ||
// the node). If we used those original constraints then the task | ||
// would incorrectly not be removed. This is why the constraints | ||
// from the service spec should be used instead. |
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.
i'm just... so proud. what a beautiful comment. truly brings a tear to my eye.
// longer exists), so we use the placement constraints from the | ||
// original task spec. | ||
placement = t.Spec.Placement | ||
} |
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.
perfect, this will also cover the network attachment tasks (if you don't know what that is, don't worry about it)
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.
Yeah, it looks like the constraint enforcer isn't concerned with the task runtime in general.
|
||
// The task should be rejected immediately. | ||
task = testutils.WatchTaskUpdate(t, watch) | ||
assert.Equal(t, api.TaskStateRejected, task.Status.State) |
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 test to round it out.
rebuilding CI, tests are Known Flaky, whoever maintains swarmkit should really get onto fixing those tests |
Codecov Report
@@ Coverage Diff @@
## master #2857 +/- ##
==========================================
+ Coverage 62.13% 62.22% +0.08%
==========================================
Files 139 139
Lines 22341 22352 +11
==========================================
+ Hits 13882 13908 +26
+ Misses 6979 6959 -20
- Partials 1480 1485 +5 |
Revendors docker/swarmkit to backport fixes made to the ConstraintEnforcer (see moby/swarmkit#2857) Signed-off-by: Drew Erny <[email protected]>
Revendors docker/swarmkit to backport fixes made to the ConstraintEnforcer (see moby/swarmkit#2857) Signed-off-by: Drew Erny <[email protected]> Upstream-commit: 56e92239a6f470fa410d7e09f2fe137b9b634de0 Component: engine
Includes the following changes since last vendoring: moby/swarmkit#2795 - Add capabilities list to container specification moby/swarmkit#2845 - Fix linting error moby/swarmkit#2848 - Bump fernet/fernet-go moby/swarmkit#2856 - Add ListServiceStatuses grpc method moby/swarmkit#2857 - Use Service Placement Constraints in Enforcer Signed-off-by: Drew Erny <[email protected]>
Includes the following changes since last vendoring: moby/swarmkit#2795 - Add capabilities list to container specification moby/swarmkit#2845 - Fix linting error moby/swarmkit#2848 - Bump fernet/fernet-go moby/swarmkit#2856 - Add ListServiceStatuses grpc method moby/swarmkit#2857 - Use Service Placement Constraints in Enforcer Signed-off-by: Drew Erny <[email protected]> Upstream-commit: 67e25ec5ac568a893e444891a6a583fd2f996f76 Component: engine
Description
What I did and how I did it
This patch updates the ConstraintEnforcer to use the placement constraints from the current service spec rather than the placement constraints from the current task spec because they may be outdated in some cases (e.g., when the service was previously updated to modify placement constrainst but the node to which the task was scheduled still satisfies the constraints. If the node is updated in a way which causes it to no longer satisfy the new constraints then the task should be removed even if it still would satisfy the original task constraints).
For the Changelog
I'm not sure how to concisely describe it, but how about:
Testing
This patch includes a new unit test in the
manager/orchestrator/constraintenforcer
package.How to test