feature: Populate NetworkSettings.Gateway - #4771
Conversation
Good suggestion, thanks! I'll add a Tigron e2e test that verifies that |
|
@haytok added the test |
AkihiroSuda
left a comment
There was a problem hiding this comment.
Please squash the commits
fc3cd88 to
c8e2272
Compare
haytok
left a comment
There was a problem hiding this comment.
When checking this CI Log, the test TestContainerInspectGateway you have added has failed, so please check your fix.
=== Failing tests ===
TestContainerInspectGateway
2b0bd48 to
ec66442
Compare
haytok
left a comment
There was a problem hiding this comment.
Before requesting a review, please make sure that the tests for the changes you’ve made have passed 🙏
| testCase.Run(t) | ||
| } | ||
|
|
||
| func TestContainerInspectGateway(t *testing.T) { |
There was a problem hiding this comment.
Have you already checked CI failures related to this fix?
ec66442 to
8f8e6fe
Compare
https://github.com/containerd/nerdctl/actions/runs/23119762664/job/67191519034?pr=4771 |
|
Marking as a draft due to the CI failure. |
NetworkSettings.Gateway is expected to be present in inspect output. nerdctl did not expose this prior to this change, even when a default gateway existed. Collect the IPv4 default gateway from the container network namespace during netns inspection, store it in the native inspect data, and propagate it to DefaultNetworkSettings.Gateway. Resolves containerd#415 Signed-off-by: Mustaeen Ahmed <contact@mustaeen.dev>
| @@ -44,6 +44,7 @@ type NetNS struct { | |||
| // Zero means unset. | |||
| PrimaryInterface int `json:"PrimaryInterface,omitempty"` | |||
| Interfaces []NetInterface `json:"Interfaces,omitempty"` | |||
| Gateway string `json:"Gateway,omitempty"` | |||
There was a problem hiding this comment.
| Gateway string `json:"Gateway,omitempty"` | |
| Gateway net.IP `json:"Gateway,omitempty"` |
Resolves #415
Issue
NetworkSettings.Gatewayis expected to be present in inspect output.nerdctldid not expose this prior to this change, even when a default gateway existed.Changes
This pull request adds a feature that allows for
NetworkSettings.Gatewayto be populated innerdctl inspectoutput.How it works:
Collects default IPv4 gateway from the container network namespace during netns inspection
Stores the gateway in inspect network data
Propagates the value to
DefaultNetworkSettings.GatewayUnit tests have also been adjusted to reflect this change.
Testing
Notes