Skip to content

fix(network): allow inspecting pseudo networks#4953

Open
immanuwell wants to merge 1 commit into
containerd:mainfrom
immanuwell:fix-network-inspect-pseudo-networks
Open

fix(network): allow inspecting pseudo networks#4953
immanuwell wants to merge 1 commit into
containerd:mainfrom
immanuwell:fix-network-inspect-pseudo-networks

Conversation

@immanuwell

@immanuwell immanuwell commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

refs #3005

nerdctl network ls shows host and none, but nerdctl network inspect host and nerdctl network inspect none still fail. the inspect path asks to allow pseudo networks, but lookup only checked on-disk CNI configs, so these names fell through. kinda awkward.

this returns a small synthetic config for pseudo networks in that lookup path, so inspect can render them fine.

repro:

  1. run nerdctl network ls
  2. see host and none
  3. run nerdctl network inspect host
  4. before: fails with no network found matching: host
  5. after: returns JSON with "Name": "host"

checks:

  • go test ./pkg/netutil -count=1
  • go test ./pkg/inspecttypes/dockercompat -count=1
  • go test ./cmd/nerdctl/network -run ^ -count=1

Comment thread pkg/netutil/netutil.go Outdated
@immanuwell immanuwell force-pushed the fix-network-inspect-pseudo-networks branch from 9871643 to 79a6561 Compare June 12, 2026 13:58
@immanuwell immanuwell requested a review from sathiraumesh June 12, 2026 13:59
@AkihiroSuda

Copy link
Copy Markdown
Member
 FAIL - does not have a valid DCO

https://github.com/containerd/nerdctl/actions/runs/27420363683/job/81044018040?pr=4953

Comment thread pkg/netutil/netutil.go Outdated
}

func newPseudoNetworkConfig(name string) (*NetworkConfig, error) {
confJSON, err := json.Marshal(struct {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this struct already defined in somewhere else?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point
I switched newPseudoNetworkConfig to reuse the existing cniNetworkConfig, and made nerdctlID / nerdctlLabels omitempty so the synthetic pseudo-network config stays minimal
PTAL

Signed-off-by: immanuwell <pchpr.00@list.ru>
@immanuwell immanuwell force-pushed the fix-network-inspect-pseudo-networks branch from 79a6561 to 5a04185 Compare June 13, 2026 06:23
@immanuwell immanuwell requested a review from AkihiroSuda June 13, 2026 06:26
@AkihiroSuda AkihiroSuda requested review from Copilot and removed request for sathiraumesh June 15, 2026 15:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes nerdctl network inspect for pseudo networks (host and none) by synthesizing a minimal, parseable CNI config when those names are requested, allowing the existing inspect rendering path to work consistently.

Changes:

  • Extend CNIEnv.ListNetworksMatch() to return a synthetic NetworkConfig for pseudo networks when allowed.
  • Add a small pseudoNetworkPlugin type and a helper to build the synthetic config.
  • Enable/expand test coverage so network inspect host|none now passes.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
pkg/netutil/netutil.go Adds pseudo-network lookup handling and synthetic config generation; tweaks JSON tags for optional fields.
pkg/netutil/netutil_test.go Adds a unit test ensuring pseudo networks are included in match results.
pkg/netutil/cni_plugin.go Introduces a minimal plugin type used for pseudo network config serialization.
cmd/nerdctl/network/network_inspect_test.go Removes the “NeedsFixing” gating so inspect host/none is exercised normally.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/netutil/netutil.go
@AkihiroSuda

Copy link
Copy Markdown
Member

test / in-host / docker failed 7 times
https://github.com/containerd/nerdctl/actions/runs/27458993998/job/81517770971?pr=4953

2026-06-15T20:35:11.1401312Z === Failing tests ===
2026-06-15T20:35:11.1401617Z TestRunSeccompCapSysPtrace
2026-06-15T20:35:11.1401881Z TestUpdateRestartPolicy
2026-06-15T20:35:11.1402103Z =====================

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants