mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-30 09:13:29 +00:00
katautils: fix shim v2 fail to work with libnetwork
detail how kata work with libnetwork 1. kata create a new netns 2. with EnterNS, kata change netns to the created one. 3. in pre-start hook, kata will re-exec libnetwork process libnetwork-setkey, and send self pid to it. libnetwork use /proc/pid/ns/net to find the netns kata use, and set veth into the netns. v1/v2 shim use the same way to create network, v1 can successful because EnterNS changed both current thread and main thread's netns. But use v2 shim, only changed current thread netns, main thread still use host netns, so it fails. Looks like v1 just lucky to be successful. In kata, `state.Pid` should be tid. Fixes: #1788 Signed-off-by: Ace-Tang <aceapril@126.com>
This commit is contained in:
parent
7aaf61d44d
commit
9c48536174
@ -11,7 +11,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
@ -39,7 +38,7 @@ func runHook(ctx context.Context, hook specs.Hook, cid, bundlePath string) error
|
|||||||
log.String("hook-args", strings.Join(hook.Args, " ")))
|
log.String("hook-args", strings.Join(hook.Args, " ")))
|
||||||
|
|
||||||
state := specs.State{
|
state := specs.State{
|
||||||
Pid: os.Getpid(),
|
Pid: syscall.Gettid(),
|
||||||
Bundle: bundlePath,
|
Bundle: bundlePath,
|
||||||
ID: cid,
|
ID: cid,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user