Unverified Commit 1ff85f09 authored by Nick Ethier's avatar Nick Ethier
Browse files

executor: cleanup netns handling in executor

parent d28d8651
Showing with 3 additions and 11 deletions
+3 -11
...@@ -10,7 +10,6 @@ import ( ...@@ -10,7 +10,6 @@ import (
"os/exec" "os/exec"
"path" "path"
"path/filepath" "path/filepath"
"runtime"
"strings" "strings"
"syscall" "syscall"
"time" "time"
...@@ -186,22 +185,15 @@ func (l *LibcontainerExecutor) Launch(command *ExecCommand) (*ProcessState, erro ...@@ -186,22 +185,15 @@ func (l *LibcontainerExecutor) Launch(command *ExecCommand) (*ProcessState, erro
// Starts the task // Starts the task
if command.NetworkIsolation != nil && command.NetworkIsolation.Path != "" { if command.NetworkIsolation != nil && command.NetworkIsolation.Path != "" {
// Lock to the thread we're changing the network namespace of
runtime.LockOSThread()
netns, err := ns.GetNS(command.NetworkIsolation.Path) netns, err := ns.GetNS(command.NetworkIsolation.Path)
if err != nil { if err != nil {
return nil, err return nil, fmt.Errorf("failed to get ns %s: %v", command.NetworkIsolation.Path, err)
} }
// Start the container in the network namespace // Start the container in the network namespace
err = netns.Do(func(ns.NetNS) error { err = netns.Do(func(ns.NetNS) error { return container.Run(process) })
if err := container.Run(process); err != nil {
container.Destroy()
return err
}
return nil
})
if err != nil { if err != nil {
container.Destroy()
return nil, err return nil, err
} }
} else { } else {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment