Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
katautils: fix shim v2 fail to work with libnetwork
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Ace-Tang committed Jun 12, 2019
1 parent 7aaf61d commit 9c48536
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/katautils/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"context"
"encoding/json"
"fmt"
"os"
"os/exec"
"strings"
"syscall"
Expand Down Expand Up @@ -39,7 +38,7 @@ func runHook(ctx context.Context, hook specs.Hook, cid, bundlePath string) error
log.String("hook-args", strings.Join(hook.Args, " ")))

state := specs.State{
Pid: os.Getpid(),
Pid: syscall.Gettid(),
Bundle: bundlePath,
ID: cid,
}
Expand Down

0 comments on commit 9c48536

Please sign in to comment.