From 97725cd6ff05d3ce91187382bac82847e6c7f923 Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Wed, 16 Aug 2017 09:27:49 -0400 Subject: [PATCH] Lock goroutine to OS thread while changing NS Prevents an issue where the goroutine may jump to a new OS thread during execution putting it into a mount/network NS that is unexpected. Signed-off-by: Brian Goff (cherry picked from commit 65bb58fad9f75b4302a972663a238e3f1a7ba3bb) Signed-off-by: Brian Goff --- drivers/overlay/ov_network.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/overlay/ov_network.go b/drivers/overlay/ov_network.go index 6dd0ec9d6e..126093fefe 100644 --- a/drivers/overlay/ov_network.go +++ b/drivers/overlay/ov_network.go @@ -8,6 +8,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "strconv" "strings" "sync" @@ -81,6 +82,10 @@ func setDefaultVlan() { logrus.Error("insufficient number of arguments") os.Exit(1) } + + runtime.LockOSThread() + defer runtime.UnlockOSThread() + nsPath := os.Args[1] ns, err := netns.GetFromPath(nsPath) if err != nil {