Skip to content

Commit

Permalink
fix: start runc with network and mount namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
bertschneider committed Jan 10, 2025
1 parent 1bff653 commit 9709b41
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion go/action_kit_commons/runc/runc.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,9 @@ func (r *defaultRunc) createSpec(ctx context.Context, bundle string) error {
}

func (r *defaultRunc) command(ctx context.Context, args ...string) *exec.Cmd {
nsenterArgs := []string{"-t", "1", "-C", "--", "runc"}
// Enter network and mount namespaces as well, as the network could be a named network namespace
// which are located in /var/run/netns and otherwise not accessible.
nsenterArgs := []string{"-t", "1", "-C", "-n", "-m", "--", "runc"}
nsenterArgs = append(nsenterArgs, r.defaultArgs()...)
nsenterArgs = append(nsenterArgs, args...)
return RootCommandContext(ctx, "nsenter", nsenterArgs...)
Expand Down
2 changes: 1 addition & 1 deletion go/action_kit_commons/runc/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ func NamespacesExists(ctx context.Context, namespaces []LinuxNamespace, nsType .

RefreshNamespace(ctx, &ns)

if _, err := os.Lstat(ns.Path); err != nil && os.IsNotExist(err) {
if _, err := executeReadInodes(ctx, ns.Path); err != nil && os.IsNotExist(err) {
return fmt.Errorf("namespace %s doesn't exist: %w", ns.Path, err)
}
}
Expand Down

0 comments on commit 9709b41

Please sign in to comment.