f-92: metadata: socket créée dans le netns du VPC, Restart=on-failure #92
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
29a96409ed
commit
da4e0a194b
6 changed files with 131 additions and 45 deletions
|
|
@ -1,5 +0,0 @@
|
|||
package netns
|
||||
|
||||
func Enter(name string) error {
|
||||
return enter(name)
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
//go:build linux
|
||||
|
||||
package netns
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func enter(name string) error {
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
path := fmt.Sprintf("/var/run/netns/%s", name)
|
||||
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
return unix.Setns(int(f.Fd()), unix.CLONE_NEWNET)
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
//go:build !linux
|
||||
|
||||
package netns
|
||||
|
||||
func enter(name string) error {
|
||||
// Ignoré hors Linux
|
||||
return nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue