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

Refactor plugin to create veths in CreateEndpoint #2412

Merged
merged 2 commits into from Jul 4, 2016
Merged

Conversation

bboreham
Copy link
Contributor

Re-doing #1808, which was pulled because we were uncertain about the semantics of create/delete vs join/leave. Subsequent Docker changes indicate that this is not something to worry about.

Fixes #1803.

By moving endpoint creation into CreateEndpoint we can return the MAC address at the time Docker expects. We find the endpoint later simply by looking it up with the same name, derived from the endpoint ID.

The second commit was also tagged onto #1808; changes from using 5 chars from the endpoint-ID to using 8, to reduce the chance of collision from ~1/1000 to ~1/64K. This is not backwards-compatible, e.g. if you stop/upgrade/start the plugin it will log a warning and leak the veth when asked to remove an endpoint.

@bboreham bboreham added this to the 1.7.0 milestone Jun 29, 2016
@@ -206,7 +211,7 @@ func (driver *driver) DiscoverDelete(disco *api.DiscoveryNotification) error {
}

func vethPair(id string) (string, string) {
return "vethwl" + id[:5], "vethwg" + id[:5]
return "vethwl" + id[:8], "vethwg" + id[:8]

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

@rade
Copy link
Member

rade commented Jul 1, 2016

Would this be safe & worthwhile for 1.6.1?

@bboreham
Copy link
Contributor Author

bboreham commented Jul 1, 2016

Would this be safe & worthwhile for 1.6.1?

No customer has asked for this feature; I just noticed it when trying to re-implement weave ps, which turned out to be unhelpful given what we had to do for CNI. So I'd have to say it falls outside of our rules for a point release.

if err := netlink.LinkDel(veth); err != nil {
// Try again using the name construction from earlier plugin version,
// in case user has upgraded with endpoints still extant
veth.Name = "vethwl" + deleteReq.EndpointID[:5]

This comment was marked as abuse.

This comment was marked as abuse.

@rade rade assigned bboreham and unassigned bboreham Jul 1, 2016
@rade rade modified the milestone: 1.8.0 Jul 1, 2016
Import library to get max name length IFNAMSIZ
@bboreham bboreham removed their assignment Jul 1, 2016
@rade
Copy link
Member

rade commented Jul 1, 2016

The switch from Join/Leave to Create/Delete makes me nervous. Does this introduce any failure modes / races / leaks?

@bboreham
Copy link
Contributor Author

bboreham commented Jul 4, 2016

The switch from Join/Leave to Create/Delete makes me nervous.

Well, that was the whole reason this change was pulled the last time. Then the Docker Overlay plugin was changed from create in Join and delete in Leave to do the veth deletion in Delete, and I asked if it mattered and didn't get much of an answer. The Docker calling code calls CreateEndpoint then Join in the same routine, with a deferred Delete if things go wrong in between.

As an alternative, we could choose the MAC using the bits from the endpoint ID.

@rade rade merged commit 333d5f7 into master Jul 4, 2016
@rade rade added this to the 1.7.0 milestone Sep 23, 2016
@bboreham bboreham deleted the 1803-plugin-create branch November 9, 2016 17:21
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.

None yet

2 participants