mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-25 18:53:44 +00:00
Merge pull request #5986 from dcantah/nydus-nonetns
nydus: net-ns handling needs to be only executed on Linux hosts
This commit is contained in:
@@ -23,7 +23,6 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containernetworking/plugins/pkg/ns"
|
|
||||||
"github.com/kata-containers/kata-containers/src/runtime/pkg/katautils/katatrace"
|
"github.com/kata-containers/kata-containers/src/runtime/pkg/katautils/katatrace"
|
||||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/utils"
|
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/utils"
|
||||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/utils/retry"
|
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/utils/retry"
|
||||||
@@ -54,8 +53,6 @@ const (
|
|||||||
nydusPassthroughfs = "passthrough_fs"
|
nydusPassthroughfs = "passthrough_fs"
|
||||||
|
|
||||||
sharedPathInGuest = "/containers"
|
sharedPathInGuest = "/containers"
|
||||||
|
|
||||||
shimNsPath = "/proc/self/ns/net"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -85,13 +82,6 @@ type nydusd struct {
|
|||||||
debug bool
|
debug bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func startInShimNS(cmd *exec.Cmd) error {
|
|
||||||
// Create nydusd in shim netns as it needs to access host network
|
|
||||||
return doNetNS(shimNsPath, func(_ ns.NetNS) error {
|
|
||||||
return cmd.Start()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (nd *nydusd) Start(ctx context.Context, onQuit onQuitFunc) (int, error) {
|
func (nd *nydusd) Start(ctx context.Context, onQuit onQuitFunc) (int, error) {
|
||||||
span, _ := katatrace.Trace(ctx, nd.Logger(), "Start", nydusdTracingTags)
|
span, _ := katatrace.Trace(ctx, nd.Logger(), "Start", nydusdTracingTags)
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
21
src/runtime/virtcontainers/nydusd_linux.go
Normal file
21
src/runtime/virtcontainers/nydusd_linux.go
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
// Copyright (c) 2017 Intel Corporation
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
package virtcontainers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os/exec"
|
||||||
|
|
||||||
|
"github.com/containernetworking/plugins/pkg/ns"
|
||||||
|
)
|
||||||
|
|
||||||
|
const shimNsPath = "/proc/self/ns/net"
|
||||||
|
|
||||||
|
func startInShimNS(cmd *exec.Cmd) error {
|
||||||
|
// Create nydusd in shim netns as it needs to access host network
|
||||||
|
return doNetNS(shimNsPath, func(_ ns.NetNS) error {
|
||||||
|
return cmd.Start()
|
||||||
|
})
|
||||||
|
}
|
15
src/runtime/virtcontainers/nydusd_other.go
Normal file
15
src/runtime/virtcontainers/nydusd_other.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright (c) 2023 Apple Inc.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
//go:build !linux
|
||||||
|
|
||||||
|
package virtcontainers
|
||||||
|
|
||||||
|
import "os/exec"
|
||||||
|
|
||||||
|
// No-op on net namespace join on other platforms.
|
||||||
|
func startInShimNS(cmd *exec.Cmd) error {
|
||||||
|
return cmd.Start()
|
||||||
|
}
|
Reference in New Issue
Block a user