Skip to content

Fix #19100 and fix a typo#19291

Merged
tiborvass merged 1 commit intomoby:masterfrom
coolljt0725:fix_19100
Jan 14, 2016
Merged

Fix #19100 and fix a typo#19291
tiborvass merged 1 commit intomoby:masterfrom
coolljt0725:fix_19100

Conversation

@coolljt0725
Copy link
Contributor

Signed-off-by: Lei Jitang [email protected]

Closes #19100
ping @tonistiigi @mavenugo
cc @thaJeztah @vikstrous

@calavera
Copy link
Contributor

LGTM

@cpuguy83
Copy link
Member

ping @mrjana @mavenugo Does this one look ok?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will break in the following scenario (but not sure how valid is the scenario though) :

docker network create xxx
docker network create yyy
docker network create zzz
docker run --net=xxx --name=foo ...
docker network connect yyy foo
docker network connect zzz foo
docker network disconnect xxx foo
docker restart foo

This will result in the container losing connectivity to networks yyy and zzz.

I have to think through other cases or possible fix. But am not even sure if we have to handle this case.

Copy link
Member

Choose a reason for hiding this comment

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

So it'll break if the first network that the container was connected to, is disconnected?

Copy link
Contributor

Choose a reason for hiding this comment

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

correct. I think so. I have to try it out to make sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mavenugo Oh yes, the scenario you describe will be break ...

@thaJeztah
Copy link
Member

oh, documentation builds can be ignored here, because there's no documentation changes in this PR

@coolljt0725
Copy link
Contributor Author

@mavenugo I has updated the fix, this should not break the scenario what you have describe.

@coolljt0725 coolljt0725 force-pushed the fix_19100 branch 2 times, most recently from c90daa4 to 71ee914 Compare January 14, 2016 03:58
Copy link
Contributor

Choose a reason for hiding this comment

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

In the case of docker create, we call SetDefaultNetModeIfBlank(hc) to setup default network mode if it is blank.
This was done as part of the windows support to provide backward compatibility.

With your fix, if the newNetworkMode is empty in ContainerStart (which I assume means use the one setup in docker create). Hence, I think we should first check if the newNetworkMode != "" before performing the above check.

WDYT ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mavenugo newNetworkMode couldn't be empty, since the hostConfig that ContainerStart passed is from runconfig.DecodeHostConfig (https://github.com/docker/docker/blob/master/api/server/router/container/container_routes.go#L174 ) and DecodeHostConfig will also call SetDefaultNetModeIfBlank(called in getHostConfig)

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool. Thanks for confirming.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we want to support changing the network mode, we only need to support setting the network mode on start (in cases where hostconfig was not passed in on create, but was on start). This should be a one time allowance.

Copy link
Contributor

Choose a reason for hiding this comment

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

@cpuguy83 wont that break backward compatibility ?
(I have to try how it behaves in 1.9.x and before)

Copy link
Member

Choose a reason for hiding this comment

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

@mavenugo If it was supported before I would consider it a bug... and not likely very used if at all.

Copy link
Contributor

Choose a reason for hiding this comment

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

sure. I agree.
But regardless of that, it will be considered as an API breakage, which we have to document.

@mavenugo
Copy link
Contributor

@coolljt0725 I like the new approach way better than the previous iteration.
Just 1 additional comment. Can you please take care of that ?

Signed-off-by: Lei Jitang <[email protected]>
@coolljt0725
Copy link
Contributor Author

@mavenugo Add a test to test the scenario you describe in #19291 (comment)

@mavenugo
Copy link
Contributor

Thanks @coolljt0725.

LGTM

@icecrime
Copy link
Contributor

LGTM

tiborvass added a commit that referenced this pull request Jan 14, 2016
@tiborvass tiborvass merged commit 349d970 into moby:master Jan 14, 2016
@coolljt0725 coolljt0725 deleted the fix_19100 branch January 15, 2016 06:04
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.

9 participants