Skip to content

Conversation

mountkin
Copy link
Contributor

Given that I have a bridge interface named br0, when I run docker network create -d bridge -o com.docker.network.bridge.name=br0 mybr and then run docker network rm mybr, the br0 interface on my host will be removed.
I think in such case the pre-configured bridge interface should not be delete by docker.

Signed-off-by: Shijiang Wei mountkin@gmail.com

@@ -674,6 +675,7 @@ func (d *driver) createNetwork(config *networkConfiguration) error {
bridgeAlreadyExists := bridgeIface.exists()
if !bridgeAlreadyExists {
bridgeSetup.queueStep(setupDevice)
config.ifaceManaged = true
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't this code mark as managed also the libnetwork created docker0 bridge ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yes. I updated the code to exclude the docker0 bridge.

@mountkin mountkin force-pushed the keep-custom-bridge branch 2 times, most recently from 7ee6d78 to 6f620ef Compare June 28, 2016 05:32
@chenchun
Copy link
Contributor

You didn't persist the flag, what if daemon restarts?

@mountkin
Copy link
Contributor Author

mountkin commented Jun 30, 2016

@chenchun That's a good question. Thanks! 👍
By the way, is the design looks ok? I'll fix the issue once the design review passed 😃
Once this is PR is accepted, I'll push a follow up PR to make the bridge driver fully compatible with pre-configured bridge interfaces.

Edit:
@'ed wrong person. Sorry for that

@chenchun
Copy link
Contributor

chenchun commented Jul 1, 2016

Design LGTM, ping @aboch

@@ -70,6 +70,7 @@ type networkConfiguration struct {
dbIndex uint64
dbExists bool
Internal bool
ifaceManaged bool
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not being persisted. I think that if we reload the daemon, the existing bridge networks will all be marked as non-managed. So if we delete one, the respective linux bridge will not be removed.

@mountkin mountkin force-pushed the keep-custom-bridge branch from 6f620ef to 26274d6 Compare July 19, 2016 12:02
@@ -674,6 +675,7 @@ func (d *driver) createNetwork(config *networkConfiguration) error {
bridgeAlreadyExists := bridgeIface.exists()
if !bridgeAlreadyExists {
bridgeSetup.queueStep(setupDevice)
config.IfaceManaged = true
Copy link
Contributor

Choose a reason for hiding this comment

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

On daemon reload, this will cause all existing networks' bridges to be kept as non-managed.
Somehow we need to make sure the existing networks in store are marked as managed, but after this feature they should not.

Maybe we can do this by adding a different flag instead, which is true only for network for which com.docker.network.bridge.name was specified at creation time. And the flag needs to be saved to store.

WDYT ?

@aboch
Copy link
Contributor

aboch commented Aug 4, 2016

@mountkin We are good with the feature, design.
I left a comment about a different flag PTAL. Thanks.

@aboch
Copy link
Contributor

aboch commented Sep 2, 2016

ping @mountkin

@mountkin
Copy link
Contributor Author

mountkin commented Sep 5, 2016

@aboch sorry for the delay.
I'll update the PR later.

@mountkin mountkin force-pushed the keep-custom-bridge branch 3 times, most recently from 23c1eb6 to ea778ce Compare September 6, 2016 05:07
@mountkin
Copy link
Contributor Author

mountkin commented Sep 6, 2016

@aboch I updated the PR. PTAL again. Thanks

const (
ifaceCreatorUnknown ifaceCreator = iota
ifaceCreatedByLibnetwork
ifaceCreatedByUser
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a minor comment, I would be less verbose

const (
    unknown ifaceCreator = iota
    libnetwork
    user
)

but that's just my opinion, it already looks good to me.

Signed-off-by: Shijiang Wei <mountkin@gmail.com>
@mountkin
Copy link
Contributor Author

mountkin commented Sep 7, 2016

@aboch PR updated

@aboch
Copy link
Contributor

aboch commented Sep 7, 2016

LGTM

1 similar comment
@chenchun
Copy link
Contributor

chenchun commented Sep 8, 2016

LGTM

@chenchun chenchun merged commit d4c39ee into moby:master Sep 8, 2016
@mountkin mountkin deleted the keep-custom-bridge branch September 8, 2016 02:48
liusdu pushed a commit to liusdu/moby that referenced this pull request Oct 30, 2017
Given that I have a bridge interface named br0, when I run
docker network create -d bridge -o com.docker.network.bridge.name=br0 mybr
and then run docker network rm mybr, the br0 interface on my host will be removed.
I think in such case the pre-configured bridge interface should not be delete by docker.

cherry-pick from moby/libnetwork#1301

fix DTS2017062908750

Signed-off-by: Shijiang Wei <mountkin@gmail.com>
Signed-off-by: Lei Jitang <leijitang@huawei.com>
liusdu pushed a commit to liusdu/moby that referenced this pull request Oct 30, 2017
don't delete the bridge interface if it was not created by libnetwork

Given that I have a bridge interface named br0, when I run
docker network create -d bridge -o com.docker.network.bridge.name=br0 mybr
and then run docker network rm mybr, the br0 interface on my host will be removed.
I think in such case the pre-configured bridge interface should not be delete by docker.

cherry-pick from moby/libnetwork#1301

fix DTS2017062908750

Signed-off-by: Shijiang Wei <mountkin@gmail.com>
Signed-off-by: Lei Jitang <leijitang@huawei.com>



See merge request docker/docker!619
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants