Conversation
d05d652 to
dccd1ec
Compare
|
LGTM |
daemon/container_operations_unix.go
Outdated
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
So it'll break if the first network that the container was connected to, is disconnected?
There was a problem hiding this comment.
correct. I think so. I have to try it out to make sure.
There was a problem hiding this comment.
@mavenugo Oh yes, the scenario you describe will be break ...
|
oh, documentation builds can be ignored here, because there's no documentation changes in this PR |
dccd1ec to
9f915a2
Compare
|
@mavenugo I has updated the fix, this should not break the scenario what you have describe. |
c90daa4 to
71ee914
Compare
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
@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)
There was a problem hiding this comment.
Cool. Thanks for confirming.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@cpuguy83 wont that break backward compatibility ?
(I have to try how it behaves in 1.9.x and before)
There was a problem hiding this comment.
@mavenugo If it was supported before I would consider it a bug... and not likely very used if at all.
There was a problem hiding this comment.
sure. I agree.
But regardless of that, it will be considered as an API breakage, which we have to document.
|
@coolljt0725 I like the new approach way better than the previous iteration. |
Signed-off-by: Lei Jitang <[email protected]>
71ee914 to
3d2539d
Compare
|
@mavenugo Add a test to test the scenario you describe in #19291 (comment) |
|
Thanks @coolljt0725. LGTM |
|
LGTM |
Signed-off-by: Lei Jitang [email protected]
Closes #19100
ping @tonistiigi @mavenugo
cc @thaJeztah @vikstrous