Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accont for non-sandbox interfaces when specifying the default network #71

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkg/utils/net-attach-def.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,12 @@ func CreateNetworkStatuses(r cnitypes.Result, networkName string, defaultNetwork

// Initialize NetworkStatus for each container interface (e.g. with sandbox present)
indexOfFoundPodInterface := 0
foundFirstSandboxIface := false
for i, iface := range result.Interfaces {
if iface.Sandbox != "" {
ns := &v1.NetworkStatus{
Name: networkName,
Default: defaultNetwork && i == 0,
Default: defaultNetwork && !foundFirstSandboxIface,
Interface: iface.Name,
Mac: iface.Mac,
Mtu: iface.Mtu,
Expand All @@ -166,6 +167,7 @@ func CreateNetworkStatuses(r cnitypes.Result, networkName string, defaultNetwork
// Map original index to the new slice index
indexMap[i] = indexOfFoundPodInterface
indexOfFoundPodInterface++
foundFirstSandboxIface = true
}
}

Expand Down
12 changes: 6 additions & 6 deletions pkg/utils/net-attach-def_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,16 @@ var _ = Describe("Netwok Attachment Definition manipulations", func() {
cniResult = &cni100.Result{
CNIVersion: "1.1.0",
Interfaces: []*cni100.Interface{
{
Name: "foo",
Mac: "00:AA:BB:CC:DD:33",
},
{
Name: "example0",
Mac: "00:AA:BB:CC:DD:01",
Sandbox: "/path/to/network/namespace",
Mtu: 1500,
},
{
Name: "foo",
Mac: "00:AA:BB:CC:DD:33",
},
{
Name: "example1",
Mac: "00:AA:BB:CC:DD:02",
Expand All @@ -252,11 +252,11 @@ var _ = Describe("Netwok Attachment Definition manipulations", func() {
IPs: []*cni100.IPConfig{
{
Address: *EnsureCIDR("192.0.2.1/24"),
Interface: &[]int{0}[0],
Interface: &[]int{1}[0],
},
{
Address: *EnsureCIDR("192.0.2.2/24"),
Interface: &[]int{0}[0],
Interface: &[]int{1}[0],
},
{
Address: *EnsureCIDR("192.0.2.3/24"),
Expand Down
Loading