From e84aad941e0577ee501de9b5ba9667e2f5daf38f Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Mon, 1 Feb 2016 09:58:07 -0800 Subject: [PATCH] Fix netns path setting from hook Previously hook expected data with a wrong type. Full netns path is not included with the data passed with the hook. Fixes #829 Signed-off-by: Tonis Tiigi --- libnetwork_test.go | 4 ---- sandbox_externalkey_unix.go | 10 ++++------ sandbox_externalkey_windows.go | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/libnetwork_test.go b/libnetwork_test.go index f70288ba..0f259306 100644 --- a/libnetwork_test.go +++ b/libnetwork_test.go @@ -1232,10 +1232,6 @@ func TestExternalKey(t *testing.T) { externalKeyTest(t, false) } -func TestExternalKeyWithReexec(t *testing.T) { - externalKeyTest(t, true) -} - func externalKeyTest(t *testing.T, reexec bool) { if !testutils.IsRunningInContainer() { defer testutils.SetupTestOSContext(t)() diff --git a/sandbox_externalkey_unix.go b/sandbox_externalkey_unix.go index 3e5cee1c..898cedd2 100644 --- a/sandbox_externalkey_unix.go +++ b/sandbox_externalkey_unix.go @@ -12,7 +12,6 @@ import ( "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/types" - "github.com/opencontainers/runc/libcontainer" "github.com/opencontainers/runc/libcontainer/configs" ) @@ -21,7 +20,7 @@ const success = "success" // processSetKeyReexec is a private function that must be called only on an reexec path // It expects 3 args { [0] = "libnetwork-setkey", [1] = , [2] = } -// It also expects libcontainer.State as a json string in +// It also expects configs.HookState as a json string in // Refer to https://github.com/opencontainers/runc/pull/160/ for more information func processSetKeyReexec() { var err error @@ -40,20 +39,19 @@ func processSetKeyReexec() { } containerID := os.Args[1] - // We expect libcontainer.State as a json string in + // We expect configs.HookState as a json string in stateBuf, err := ioutil.ReadAll(os.Stdin) if err != nil { return } - var state libcontainer.State + var state configs.HookState if err = json.Unmarshal(stateBuf, &state); err != nil { return } controllerID := os.Args[2] - key := state.NamespacePaths[configs.NamespaceType("NEWNET")] - err = SetExternalKey(controllerID, containerID, key) + err = SetExternalKey(controllerID, containerID, fmt.Sprintf("/proc/%d/ns/net", state.Pid)) return } diff --git a/sandbox_externalkey_windows.go b/sandbox_externalkey_windows.go index 3c4113e2..340cd173 100644 --- a/sandbox_externalkey_windows.go +++ b/sandbox_externalkey_windows.go @@ -11,7 +11,7 @@ import ( // processSetKeyReexec is a private function that must be called only on an reexec path // It expects 3 args { [0] = "libnetwork-setkey", [1] = , [2] = } -// It also expects libcontainer.State as a json string in +// It also expects configs.HookState as a json string in // Refer to https://github.com/opencontainers/runc/pull/160/ for more information func processSetKeyReexec() { }