Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Gracefully handle network bridge without IP association at startup#8453

Merged
aluzzardi merged 1 commit into
moby:masterfrom
estesp:8444-create-bridge-error
Oct 24, 2014
Merged

Gracefully handle network bridge without IP association at startup#8453
aluzzardi merged 1 commit into
moby:masterfrom
estesp:8444-create-bridge-error

Conversation

@estesp

@estesp estesp commented Oct 7, 2014

Copy link
Copy Markdown
Contributor

Addresses #8444

Docker-DCO-1.1-Signed-off-by: Phil Estes [email protected] (github: estesp)

@crosbymichael

Copy link
Copy Markdown
Contributor

ping @aluzzardi

@crosbymichael crosbymichael added this to the 1.3.0 milestone Oct 7, 2014
Comment thread daemon/networkdriver/bridge/driver.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a more robust way to check this error rather than doing a string matching?

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.

It would be nice to have a cleaner way to check for bridge existence, and I looked into that first before ending up with this solution. At this point, to do something more like a bridge existence check rather than test for error we would need a new API in libcontainer netlink layer similar to what you can do with brctl show to query a bridge.

The "file exists" response is a well-known return from the RTNETLINK layer, not something from Go and/or Docker, so is presumed quite stable as far as depending on it to not change in Linux as a syscall response.

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.

Probably cast to syscall.Errno and compare to syscall.EEXIST

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since this error is thrown by the syscall, would os.IsNotExist work here?

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.

os.IsExist should work.

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.

Ah nice--I'm new enough to Go to have no idea that existed (no pun intended). I can test and verify.

@aluzzardi aluzzardi removed this from the 1.3.0 milestone Oct 7, 2014
@estesp estesp force-pushed the 8444-create-bridge-error branch from c880ff6 to 0008a0a Compare October 7, 2014 21:55
@estesp

estesp commented Oct 7, 2014

Copy link
Copy Markdown
Contributor Author

Thanks for the help--os.IsExist() works. ping @aluzzardi @LK4D4 PTAL

@aluzzardi

Copy link
Copy Markdown
Member

Tests seem to be failing, please have a look at the drone link.

@estesp

estesp commented Oct 8, 2014

Copy link
Copy Markdown
Contributor Author

hrm.. @aluzzardi no idea why--tests passed here 4 times, but Jess offered to restart on drone and it was successful

@aluzzardi

Copy link
Copy Markdown
Member

Awesome.

I know this is may not be feasible given the current testing framework we have, but could you look around in unit tests / integration tests to see if it would be possible to add a test for this?

@estesp

estesp commented Oct 8, 2014

Copy link
Copy Markdown
Contributor Author

Thought about tests while I was looking into this. Could be my lack of understanding of the tests but I'm not sure how to set up the right environment and test that the daemon either starts properly or fails--which is what would be required in this case. I need docker0 to exist, but I need to remove or verify it has no IP and then start the daemon. The integration-cli tests seem to have a daemon running and are testing various client-side operations (build, run, inspect, link). Integration seems to have the ability to hack up daemon start/stop and settings, but from what I understand those tests are supposed to be migrated to integration-cli over time. If you have any ideas on how to test the daemon start/stop with a specific environment, I'm happy to create the test but don't see where it fits the current methodology at the moment.

@jessfraz

jessfraz commented Oct 8, 2014

Copy link
Copy Markdown
Contributor

here is an example of a daemon restart ttest:
https://github.com/docker/docker/blob/master/integration-cli/docker_cli_exec_test.go#L109

On Tue, Oct 7, 2014 at 6:21 PM, Phil Estes [email protected] wrote:

Thought about tests while I was looking into this. Could be my lack of
understanding of the tests but I'm not sure how to set up the right
environment and test that the daemon either starts properly or fails--which
is what would be required in this case. I need docker0 to exist, but I
need to remove or verify it has no IP and then start the daemon. The
integration-cli tests seem to have a daemon running and are testing various
client-side operations (build, run, inspect, link). Integration seems to
have the ability to hack up daemon start/stop and settings, but from what I
understand those tests are supposed to be migrated to integration-cli over
time. If you have any ideas on how to test the daemon start/stop with a
specific environment, I'm happy to create the test but don't see where it
fits the current methodology at the moment.


Reply to this email directly or view it on GitHub
#8453 (comment).

@estesp

estesp commented Oct 8, 2014

Copy link
Copy Markdown
Contributor Author

Thanks @jfrazelle for the pointer--I know what to do now :) I'll see if I can get a test working and add to this PR

@estesp estesp force-pushed the 8444-create-bridge-error branch from 0008a0a to 1150f04 Compare October 8, 2014 19:38
@estesp

estesp commented Oct 8, 2014

Copy link
Copy Markdown
Contributor Author

ping @aluzzardi @jfrazelle test added. PTAL

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.

what sucks is if we fail after this to recreate the bridge will all the other test be screwed... I would rather have that I think than no test at all but idk

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.

If there is worry about destroying the environment, a simple brctl delbr docker0 added to the failure path will make sure that any future daemon starts will work even without the fix for this issue. However, I wasn't sure about the environment this test is running in--whether I could/should depend on brctl being available. Another option is to save the IP and restore in the failure path.

@estesp

estesp commented Oct 18, 2014

Copy link
Copy Markdown
Contributor Author

Now that the 1.3.0 push is over, any followup comments or concerns on this PR? @aluzzardi @jfrazelle

@jessfraz

Copy link
Copy Markdown
Contributor

I would rather have a test than no test at all so LGTM but maybe we should add a fix me explaining what happens when the test fails

@jessfraz

Copy link
Copy Markdown
Contributor

especially in the Error for when it fails, so if it does other people aren't hunting down why the network became all screwy

EDIT: sorry clicked the wrong button below...

@jessfraz jessfraz closed this Oct 20, 2014
@jessfraz jessfraz reopened this Oct 20, 2014
@estesp estesp force-pushed the 8444-create-bridge-error branch from 1150f04 to 6ed75ec Compare October 20, 2014 17:53
@estesp

estesp commented Oct 20, 2014

Copy link
Copy Markdown
Contributor Author

good point--added a big "WARNING**" string to the error log output; let me know if you want it formatted differently

@jessfraz

Copy link
Copy Markdown
Contributor

ah perfect thanks

@estesp estesp force-pushed the 8444-create-bridge-error branch from 4934d2e to 8482897 Compare October 22, 2014 21:08
Addresses moby#8444

Docker-DCO-1.1-Signed-off-by: Phil Estes <[email protected]> (github: estesp)
@estesp estesp force-pushed the 8444-create-bridge-error branch from 8482897 to 1262b5f Compare October 23, 2014 20:19
@estesp

estesp commented Oct 23, 2014

Copy link
Copy Markdown
Contributor Author

rebased, drone failures, sweated over tests, fixed tests, rebased again.. now I hope this is actually ready to merge now :) @aluzzardi have you had a chance to look at this?

@aluzzardi

Copy link
Copy Markdown
Member

Awesome, thanks for adding tests.

LGTM

aluzzardi added a commit that referenced this pull request Oct 24, 2014
Gracefully handle network bridge without IP association at startup
@aluzzardi aluzzardi merged commit a76c924 into moby:master Oct 24, 2014
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