Skip to content

Commit f17189a

Browse files
author
Samuel Ortiz
committed
ocihook: Add a networking namespace annotation key
With VM based runtimes (e.g. Kata), the spec.State.Pid value does not necessarily runs in the container/pod networking namespace, but can also be in the host one. With those runtime, using the passed Pid to resolve the networking namespace for OCI plugins to be used result in setting the container network entirely in the host namespace. We add a "nerdct/network-namespace" for runtimes to explictly tell nerdctl which netns path to use instead of deriving it from the runtime PID. Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
1 parent f1aab17 commit f17189a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pkg/ocihook/ocihook.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ import (
4444
"github.com/sirupsen/logrus"
4545
)
4646

47+
const (
48+
// NetworkNamespace is the network namespace path to be passed to the CNI plugins.
49+
// When this annotation is set from the runtime spec.State payload, it takes
50+
// precedence over the PID based resolution (/proc/<pid>/ns/net) where pid is
51+
// spec.State.Pid.
52+
// This is mostly used for VM based runtime, where the spec.State PID does not
53+
// necessarily lives in the created container networking namespace.
54+
NetworkNamespace = labels.Prefix + "network-namespace"
55+
)
56+
4757
func Run(stdin io.Reader, stderr io.Writer, event, dataStore, cniPath, cniNetconfPath string) error {
4858
if stdin == nil || event == "" || dataStore == "" || cniPath == "" || cniNetconfPath == "" {
4959
return errors.New("got insufficient args")

0 commit comments

Comments
 (0)