fix(network): allow inspecting pseudo networks#4953
Conversation
9871643 to
79a6561
Compare
https://github.com/containerd/nerdctl/actions/runs/27420363683/job/81044018040?pr=4953 |
| } | ||
|
|
||
| func newPseudoNetworkConfig(name string) (*NetworkConfig, error) { | ||
| confJSON, err := json.Marshal(struct { |
There was a problem hiding this comment.
Isn't this struct already defined in somewhere else?
There was a problem hiding this comment.
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>
79a6561 to
5a04185
Compare
There was a problem hiding this comment.
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 syntheticNetworkConfigfor pseudo networks when allowed. - Add a small
pseudoNetworkPlugintype and a helper to build the synthetic config. - Enable/expand test coverage so
network inspect host|nonenow 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.
|
|
refs #3005
nerdctl network lsshowshostandnone, butnerdctl network inspect hostandnerdctl network inspect nonestill 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:
nerdctl network lshostandnonenerdctl network inspect hostno network found matching: host"Name": "host"checks:
go test ./pkg/netutil -count=1go test ./pkg/inspecttypes/dockercompat -count=1go test ./cmd/nerdctl/network -run ^ -count=1