-
Notifications
You must be signed in to change notification settings - Fork 619
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Honor task desired state in allocator #435
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think
t.DesiredState == api.TaskStateDead
is a sufficient condition. Does the allocator care about the observed 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.
Yeah I thought about that but decided that we don't want to deallocate the network resources for the task until the task is actually not running in the node, because otherwise we might provide the same IP address to more than one running containers even though one of them might be going down
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.
Makes sense. I just thought of this after adding the comment.
But doesn't this mean that if a node fails, we will never free the network resources associated with the tasks it was running? What's the right behavior here?
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 am assuming that if the node fails, the task will be removed. That is why I am checking task dead or
isDelete
here: https://github.com/docker/swarm-v2/pull/435/files#diff-119d353212583d96a59cba8c82b80280R254 while deciding if I want to deallocate.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.
Tasks from failed node won't be immediately deleted, to provide task history. Instead, they generally have
DesiredState
set toDEAD
.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.
Hmm.. When will they be removed? I realized this as well when I was doing further testing with manager restart. Seems like we retain dead nodes and I was not handling that properly in
doNetworkInit
.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 have a PR I'm going to open later today for this. The idea is that we will keep a certain number of old tasks per service instance, and then start deleting the oldest ones.
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.
As discussed offline, there is no perfect solution to this. The current approach in the PR is the most conservative, since it will favor leaking resources over reusing them in a dangerous way. This seems like the right place to start, but in the future we might have to iterate on the approach.