Clarify portable host network namespace detection for NRI plugins

Open
#363 8 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 6 days

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
go

Research direction

Start by reading NRI's LinuxNamespace definition in pkg/api/api.proto and the network-device injector at plugins/network-device-injector/network-device-injector.go. Compare the namespace metadata delivered during CreateContainer across the CRI-O and containerd cases described in the issue. Done means documenting the supported runtime-independent detection guarantees, or specifying additive metadata that distinguishes unknown from false.

Written by the indexing model from the issue text.

Description

Problem

An NRI plugin needs to determine whether a pod or container shares the host network namespace, including during CreateContainer.

For equivalent Linux pods using hostNetwork: true, the runtime OCI code paths reviewed expose different namespace representations:

Object CRI-O containerd with a pause sandbox
Sandbox Explicit network entry pointing to a pinned host namespace network entry omitted
Container network entry omitted Explicit entry pointing to /proc/<sandbox-pid>/ns/net, which refers to the host network namespace

Both representations are valid under OCI namespace semantics. However, checking for the presence or absence of a network entry does not provide portable host-network detection.

NRI’s LinuxNamespace contains only type and path. It does not explicitly identify whether a referenced namespace is the host namespace.

Why this matters

Plugins that configure networking or move network devices need to distinguish host networking from an isolated pod network before taking action.

This assumption also appears in the sample network-device injector: it treats an empty sandbox network namespace path as host networking. An explicit path can also refer to the host namespace, as in CRI-O’s sandbox representation.

How to verify

  1. Run an NRI logging plugin with CRI-O and containerd.
  2. Create equivalent pods with hostNetwork: true, and control pods with hostNetwork: false.
  3. Log PodSandbox.Linux.Namespaces and Container.Linux.Namespaces in CreateContainer.
  4. Compare the network namespace entries.

The table above describes the reviewed OCI code paths; captured NRI callback payloads are not included here.

Requested clarification

What is the supported, runtime-independent way to identify host networking from NRI metadata?

In particular:

  • Are namespace lists intended to preserve OCI configuration, or describe resolved namespace membership?
  • What guarantees apply to sandbox namespace metadata, whose protobuf field is marked “for NRI v1 emulation”?
  • Can plugins determine host networking during CreateContainer without runtime-specific annotations or inspecting namespace files?

If the existing API cannot express this directly, could NRI consider additive host-network metadata, with an explicit distinction between unknown and false? The existing namespace lists could retain their OCI representation.

Environment

  • CRI-O version: 1.37.4
  • containerd version: 2.3.4
  • containerd sandbox implementation: pause-based
  • Kubernetes version: v1.37.1

Credits

Co-authored and explored with @bkotlowski.

Dominant language
Go
Stars
419
Forks
105
Avg merge
9d 7h
Merged PRs (30d)
14

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from containerd/nri

All issues in containerd/nri

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.