Use libcontainer hook for network namespace info passing to libnetwork's sandbox#16305
Conversation
d0b5705 to
ab985e9
Compare
daemon/container_unix.go
Outdated
There was a problem hiding this comment.
When do we store the sandbox id now ?
There was a problem hiding this comment.
@aboch good question. I think instead of removing this call, we should move this under a check
if !execdriver.SupportsHooks(). And for native driver, we should set the sandbox-id here and set the sandbox-key (container *Container) setExternalKey. WDYT ?
There was a problem hiding this comment.
Isn't the sandbox id is the same in both cases (w/ hooks and w/o hooks). Also I think the string returned by Sandbox.Key() which is coming from osl.Generatekey(containerID string) is the same in both cases, given it only takes the container id as input.
If both the above hold true, maybe we do not need to move this call.
There was a problem hiding this comment.
I'm not necessarily an expert on libnetwork, but looking at the code, I think @aboch is correct, in that there is sort of some term overloading here of the use of "Key"; setExternalKey operations are not actually setting the sb.Key(), which remains a short variant of the container ID.
I think this call can/should stay, as I don't see where these values are going to be set on the container.NetworkSettings anywhere else?
There was a problem hiding this comment.
Also, if we set the ID during the container setup, that would be available at pre-start hook time, meaning we don't need to do a walk of sandboxes--could just use the netController.SandboxByID(..) method, right?
There was a problem hiding this comment.
@estesp @aboch that's correct. we can undo the removal of updateSandboxNetworkSettings.
But, to make things right, we should not set NamespacePath: c.NetworkSettings.SandboxKey, in populateCommand for native driver since it will not be used after this PR.
Though having it there will not cause any extra harm, it is better to be explicit and not set it when SupportHooks is enabled. WDYT ?
There was a problem hiding this comment.
@estesp updated my patch mavenugo@508c0f9 with the above change. PTAL and use it if you agree.
There was a problem hiding this comment.
Thanks @mavenugo. I've updated the PR, but until Jenkins problems are resolved we won't have validation via CI. I have run it locally to verify it is working for basic cases.
0dd2d05 to
de5e4bf
Compare
daemon/execdriver/native/create.go
Outdated
There was a problem hiding this comment.
this return nil is not necessary
|
@estesp overall, LGTM. Let's see if we can have CI checking this soon. |
|
@mavenugo @aboch I think we have a design problem here somewhere with the sandbox/external key setting that needs your help. Any test doing network namespace sharing ( These (netns sharing with host/containers) are functionalities that will be blocked--I believe, at least until there is a known solution--when running with user namespaces, so maybe the external key setting needs to be used only when user namespaces are in use? Any other solution to this that makes sense? |
|
@estesp Please hold on applying the patch. More changes coming. |
|
Sure. No problem Sent from my iPhone
|
|
@aboch because the tests were already running when you mentioned further changes were necessary, the general result of the first patch is that it fixes the prior errors on container start, but For example: |
|
@estesp apologies on the delay. the |
de5e4bf to
7bf1591
Compare
|
Thanks @mavenugo! Tested locally and |
|
@estesp pls squash the commits. there is no point having a git history that changes between array to structure :). Also thanks for the confirmation. |
|
@mavenugo I was keeping them separate as that gives you proper attribution for the original idea.. but I'm fine either way |
|
@calavera this is ready for final review.. I have a full (successful) run locally and it looks like we might get a clean Windows run from Jenkins as well |
|
@estesp I understand and appreciate it. am absolutely fine squashing it :) |
daemon/execdriver/driver.go
Outdated
There was a problem hiding this comment.
Can you assign a var name to int or document what int is expected to be here?
There was a problem hiding this comment.
Sure, I'm fine with that. I think I will just document in the updated comment if that's ok with you as this code has actually been here a long time (but only used internally as the start callback for pid info, which is what the int is)
Using @mavenugo's patch for enabling the libcontainer pre-start hook to be used for network namespace initialization (correcting the conflict with user namespaces); updated the boolean check to the more generic SupportsHooks() name, and fixed the hook state function signature. Signed-off-by: Madhu Venugopal <madhu@docker.com> Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
7bf1591 to
e148e76
Compare
|
LGTM |
|
All green! Everything bad I said about you, janky, I take it all back :) |
|
LGTM |
Use libcontainer hook for network namespace info passing to libnetwork's sandbox
Use the new hook functionality from runC/libcontainer to perform the setting of the network namespace path into libnetwork's sandbox entity. This is the final required step to solve the conflict between user namespaces and the (original) libnetwork network namespace setup flow. See #15187 for more details.
Thanks @mavenugo for the original design.