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

Use Service Placement Constraints in Enforcer #2857

Merged
merged 1 commit into from
May 20, 2019

Conversation

jlhawn
Copy link
Contributor

@jlhawn jlhawn commented May 17, 2019

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:

Fixed an issue where the constraint enforcer would not correctly reject service tasks with outdated placement constraints.

Testing

This patch includes a new unit test in the manager/orchestrator/constraintenforcer package.

How to test

$ go test github.com/docker/swarmkit/manager/orchestrator/constraintenforcer -v -run TestOutdatedTaskPlacementConstraints
=== RUN   TestOutdatedTaskPlacementConstraints
--- PASS: TestOutdatedTaskPlacementConstraints (0.00s)
PASS
ok  	github.com/docker/swarmkit/manager/orchestrator/constraintenforcer	0.022s

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)
Copy link
Collaborator

@dperny dperny left a 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.
Copy link
Collaborator

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
}
Copy link
Collaborator

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)

Copy link
Contributor Author

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)
Copy link
Collaborator

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.

@dperny
Copy link
Collaborator

dperny commented May 17, 2019

rebuilding CI, tests are Known Flaky, whoever maintains swarmkit should really get onto fixing those tests

@codecov
Copy link

codecov bot commented May 17, 2019

Codecov Report

Merging #2857 into master will increase coverage by 0.08%.
The diff coverage is 85.71%.

@@            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

@dperny dperny merged commit 1e20cbf into moby:master May 20, 2019
@jlhawn jlhawn deleted the update_constraint_enforcer branch May 20, 2019 16:44
dperny added a commit to dperny/docker that referenced this pull request May 20, 2019
Revendors docker/swarmkit to backport fixes made to the
ConstraintEnforcer (see moby/swarmkit#2857)

Signed-off-by: Drew Erny <[email protected]>
docker-jenkins pushed a commit to docker-archive/docker-ce that referenced this pull request May 21, 2019
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
dperny added a commit to dperny/docker that referenced this pull request May 24, 2019
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]>
docker-jenkins pushed a commit to docker-archive/docker-ce that referenced this pull request May 26, 2019
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants