add support --net=container with --mac-address, --add-host error out#11516
Conversation
87daa6f to
98d3d82
Compare
|
For reference, the "conflict" was added in #7780. Looking at the referenced bug, I'm not sure anyone consciously decided that Adding your other "conflicts" (dns and mac addr. when --net=container) make sense to me. @LK4D4 can you take a look? |
|
ping @estesp @LK4D4 @jfrazelle |
|
ping @estesp @cpuguy83 @jfrazelle @LK4D4 WDYT? |
|
hi all, WDYT? |
daemon/container.go
Outdated
There was a problem hiding this comment.
This one is hurting my head.
Would it be better to have a if config.NetworkMode.IsBridge() {, and then it's only one check, and it's a positive check?
If/when we have something more complicated than that we can always adjust (not that as it currently is wouldn't need to be adjusted anyway).
There was a problem hiding this comment.
Also I think this would need to be &&, not ||, since if anytime it's not host it wouldn't run the 2nd check anyway.
There was a problem hiding this comment.
And maybe instead of even that, we can do an IsShared(), assuming anything that is sharing can't change existing network options, and get rid of the need for multiple checks in runconfig.Parse
There was a problem hiding this comment.
my mistake here, This should be !config.NetworkMode.IsHost() && !config.NetworkMode.IsContainer() or config.NetworkMode.IsBridge || config.NetworkMode.IsNone, since only --net=bridge and --net=none has its
own private network stack at this time.
Do the checking in runconfig.Parse is to info the user
the setting for shared network mode is invalid or we have some
docs to tell the user what they can set in shared net mode.
|
Some comments, also needs a rebase. |
98d3d82 to
9e65c93
Compare
|
updated ping @cpuguy83 |
runconfig/parse.go
Outdated
There was a problem hiding this comment.
prefer positive checks instead of negative ones.
So if netMode.IsHost() || netMode.IsContainer()
|
Maybe in a separate PR we can refactor this code so we aren't branching quite so much. |
|
@coolljt0725 this needs a quick rebase due to merging the --link/--net=container test PR #11686. Also, I think this PR should not remove that conflict, as your other PR (#11369) fixed linking to a To be clear, I can get an error when I start 2 containers "foo" and "bar", and then try to link to one and set network to the other: This produces a "can't find parent IP" error on container start. Of course, now that #11686 is merged, you can't produce this error on master as the use of the flags together now is correctly producing a conflicts error on parse of runconfig. However, I agree with your added and corrected "conflicts" in this PR for |
9e65c93 to
1d6d59e
Compare
|
@estesp I see, I was a bit of confused at that time. the PR is updated. The first commit is to refactor the code of checking conflict option with |
9f47a34 to
f4632b6
Compare
|
These checks also need to happen in |
runconfig/parse.go
Outdated
There was a problem hiding this comment.
Typo in name ErrConfiictNetworkHosts
|
@cpuguy83 are you comments still valid with the job removal work? |
|
Yes, but I think it should go in |
|
@cpuguy83 This is a problem to move this check to |
|
Sorry, this needs another rebase :-( |
9085375 to
c9a80d1
Compare
runconfig/parse.go
Outdated
There was a problem hiding this comment.
This looks like it can be combined with the check above it.
|
One nit, but LGTM. |
9fcf02c to
90fd6c5
Compare
|
update as @cpuguy83 's suggestion |
Signed-off-by: Lei Jitang <leijitang@huawei.com>
90fd6c5 to
0e08e9a
Compare
Signed-off-by: Lei Jitang <leijitang@huawei.com>
|
rebased because github show it contain conflict |
|
LGTM |
…ag_in_container_netmode add support --net=container with --mac-address, --add-host error out
|
thanks! |
…e_flag_in_container_netmode add support --net=container with --mac-address, --add-host error out
Signed-off-by: Lei Jitang leijitang@huawei.com
There are two commits in this PR, the first one is to do clean up
for
--net=containerwith--link. The previous code suppose toprevent user from using
--linkwith--net=container,but the code
if *flNetMode == "container"never workbecause the value of
*flNetModeshouldbe like this
container:xxxx, so both of us think--net=containerwith
--linkis a desired behavior,so I created PR #11369 (sorry for didn't realize it wasn't a
desired behavior at that time). What should
we do? revert #11369 and prevent user from using
--linkwith
--net=containeror keep #11369 and clean up theinvalid conflict checking? ping @LK4D4 @estesp @icecrime
The second commits is to fix
--net=containerwith--dnsno error out,it's the same problem,
if *flNetMode == "container" && flDns.Len() > 0never work. Since a container with
--net=containermeans it have the same
dns, hosts, mac addresswith its parent,--add-host, --mac-addressis invalid on creation,so we should error out when user use these option on creation with
--net=container