Skip to content

moved updateToStore call in CreateEndPoint before we call addEndpoint#2024

Merged
fcrisciani merged 1 commit intomoby:masterfrom
selansen:master
Dec 13, 2017
Merged

moved updateToStore call in CreateEndPoint before we call addEndpoint#2024
fcrisciani merged 1 commit intomoby:masterfrom
selansen:master

Conversation

@selansen
Copy link
Copy Markdown
Contributor

@selansen selansen commented Nov 30, 2017

This is to address issue #1850 .

While creating NetworkEndpoint , if DockerD crashes before saving the object into store there will be Veth interface leak on the host. To address this issue, updateToStore call is moved up in the code flow before creating addEndpoint. In case of failure during addEndpoint, we delete from store with defer func. So it should be taken care in the event of failure in later point.

Signed-off-by: selansen elango.siva@docker.com

@GordonTheTurtle
Copy link
Copy Markdown

Please sign your commits following these rules:
https://github.com/moby/moby/blob/master/CONTRIBUTING.md#sign-your-work
The easiest way to do this is to amend the last commit:

$ git clone -b "master" git@github.com:selansen/libnetwork.git somewhere
$ cd somewhere
$ git rebase -i HEAD~842354469720
editor opens
change each 'pick' to 'edit'
save the file and quit
$ git commit --amend -s --no-edit
$ git rebase --continue # and repeat the amend for each commit
$ git push -f

Amending updates the existing PR. You DO NOT need to open a new one.

@selansen selansen changed the title moved updateToStore call in CreateEndPoint before we call addEndpoint [Do not Merge] moved updateToStore call in CreateEndPoint before we call addEndpoint Dec 4, 2017
@codecov-io
Copy link
Copy Markdown

codecov-io commented Dec 6, 2017

Codecov Report

❗ No coverage uploaded for pull request base (master@822e5b5). Click here to learn what that means.
The diff coverage is 12.5%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #2024   +/-   ##
=========================================
  Coverage          ?   39.94%           
=========================================
  Files             ?      137           
  Lines             ?    22117           
  Branches          ?        0           
=========================================
  Hits              ?     8834           
  Misses            ?    11980           
  Partials          ?     1303
Impacted Files Coverage Δ
network.go 63.29% <12.5%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 822e5b5...e253a2b. Read the comment docs.

@selansen selansen changed the title [Do not Merge] moved updateToStore call in CreateEndPoint before we call addEndpoint moved updateToStore call in CreateEndPoint before we call addEndpoint Dec 6, 2017
Comment thread network.go Outdated

if err = n.getController().updateToStore(ep); err != nil {
//Commented out and calling same API before calling addEndPoint
/*if err = n.getController().updateToStore(ep); err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about removing this code block instead of keeping it commented? Since git will store the previous version of the code, good comments alone may be sufficient. Commented code blocks are somewhat rendundant (and potentially confusing).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. Will wait for other's comment and will incorporate all review comments together.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep +1 for that

@selansen
Copy link
Copy Markdown
Contributor Author

selansen commented Dec 7, 2017

review comments are taken care.

Comment thread network.go Outdated
}()

if err = n.addEndpoint(ep); err != nil {
//Moving updateToSTore before calling addEndpoint so that we shall clean up VETH interfaces in case
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor stylistic nit: I think typical convention for comments is to add a space between // and the comment line. So something like // Moving updateToStore would be ideal. Same applies to the line below.

Copy link
Copy Markdown
Contributor

@ddebroy ddebroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except for a very minor nit. Someone else should review too.

VETH interface was not cleaned up when DockerD got killed between addEndpoint and updateToStore calls.
I have added logs and made sure calling updateToStore before addEndpoint contains same values.
Hence moving up the call looks safer and VETH gets cleaned up even after DockerD gets killed in the middle.

Signed-off-by: selansen <elango@docker.com>
@selansen
Copy link
Copy Markdown
Contributor Author

All the code review comments incorporated. @fcrisciani could you pls merge it into main stream?

@fcrisciani
Copy link
Copy Markdown

LGTM

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.

5 participants