Skip to content

Commit

Permalink
e2e: Avoid setting wrong routes for host-local IPAM
Browse files Browse the repository at this point in the history
The IPAM configuration:

```
{
"type":"host-local",
"subnet":"10.10.10.0{"type":"host-local",
"subnet":"10.10.10.0/24",
"rangeStart":"10.10.10.171",
"rangeEnd":"10.10.10.181",
"routes":[{"dst":"0.0.0.0/0"}],
"gateway":"10.10.10.1"
}
```

Can lead to the following pod `ip route` configuration:
```
default via 10.10.10.1 dev net1
default via 10.128.0.1 dev eth0
10.10.10.0/24 dev net1 proto kernel scope link src 10.10.10.172
10.128.0.0/23 dev eth0 proto kernel scope link src 10.128.0.135
10.128.0.0/14 via 10.128.0.1 dev eth0
```

which causes connectivity issues.

Avoid setting default routes to unknown gateways.

Signed-off-by: Andrea Panattoni <[email protected]>
  • Loading branch information
zeeke committed Dec 4, 2024
1 parent 5f492e5 commit 5cfd6d9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 27 deletions.
6 changes: 3 additions & 3 deletions test/conformance/tests/test_networkpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ var _ = Describe("[sriov] NetworkPool", Ordered, func() {
},
Spec: sriovv1.SriovNetworkSpec{
ResourceName: resourceName,
IPAM: `{"type":"host-local","subnet":"10.10.10.0/24","rangeStart":"10.10.10.171","rangeEnd":"10.10.10.181","routes":[{"dst":"0.0.0.0/0"}],"gateway":"10.10.10.1"}`,
IPAM: `{"type":"host-local","subnet":"10.10.10.0/24","rangeStart":"10.10.10.171","rangeEnd":"10.10.10.181"}`,
NetworkNamespace: namespaces.Test,
MetaPluginsConfig: `{"type": "rdma"}`,
}}
Expand All @@ -197,7 +197,7 @@ var _ = Describe("[sriov] NetworkPool", Ordered, func() {
},
Spec: sriovv1.SriovNetworkSpec{
ResourceName: resourceName,
IPAM: `{"type":"host-local","subnet":"10.10.10.0/24","rangeStart":"10.10.10.171","rangeEnd":"10.10.10.181","routes":[{"dst":"0.0.0.0/0"}],"gateway":"10.10.10.1"}`,
IPAM: `{"type":"host-local","subnet":"10.10.10.0/24","rangeStart":"10.10.10.171","rangeEnd":"10.10.10.181"`,
NetworkNamespace: namespaces.Test,
}}

Expand Down Expand Up @@ -318,7 +318,7 @@ var _ = Describe("[sriov] NetworkPool", Ordered, func() {
},
Spec: sriovv1.SriovNetworkSpec{
ResourceName: resourceName,
IPAM: `{"type":"host-local","subnet":"10.10.10.0/24","rangeStart":"10.10.10.171","rangeEnd":"10.10.10.181","routes":[{"dst":"0.0.0.0/0"}],"gateway":"10.10.10.1"}`,
IPAM: `{"type":"host-local","subnet":"10.10.10.0/24","rangeStart":"10.10.10.171","rangeEnd":"10.10.10.181"`,
NetworkNamespace: namespaces.Test,
}}

Expand Down
8 changes: 3 additions & 5 deletions test/conformance/tests/test_policy_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ var _ = Describe("[sriov] operator", Ordered, func() {
},
Spec: sriovv1.SriovNetworkSpec{
ResourceName: resourceName,
IPAM: `{"type":"host-local","subnet":"10.10.10.0/24","rangeStart":"10.10.10.171","rangeEnd":"10.10.10.181","routes":[{"dst":"0.0.0.0/0"}],"gateway":"10.10.10.1"}`,
IPAM: `{"type":"host-local","subnet":"10.10.10.0/24","rangeStart":"10.10.10.171","rangeEnd":"10.10.10.181"}`,
NetworkNamespace: namespaces.Test,
}}

Expand Down Expand Up @@ -483,9 +483,7 @@ var _ = Describe("[sriov] operator", Ordered, func() {
"type":"host-local",
"subnet":"10.10.10.0/24",
"rangeStart":"10.10.10.171",
"rangeEnd":"10.10.10.181",
"routes":[{"dst":"0.0.0.0/0"}],
"gateway":"10.10.10.1"
"rangeEnd":"10.10.10.181"
}`

err = network.CreateSriovNetwork(clients, unusedSriovDevice, sriovNetworkName, namespaces.Test, operatorNamespace, resourceName, ipam)
Expand Down Expand Up @@ -600,7 +598,7 @@ var _ = Describe("[sriov] operator", Ordered, func() {
},
Spec: sriovv1.SriovNetworkSpec{
ResourceName: resourceName,
IPAM: `{"type":"host-local","subnet":"10.10.10.0/24","rangeStart":"10.10.10.171","rangeEnd":"10.10.10.181","routes":[{"dst":"0.0.0.0/0"}],"gateway":"10.10.10.1"}`,
IPAM: `{"type":"host-local","subnet":"10.10.10.0/24","rangeStart":"10.10.10.171","rangeEnd":"10.10.10.181"`,
NetworkNamespace: namespaces.Test,
}}

Expand Down
28 changes: 9 additions & 19 deletions test/conformance/tests/test_sriov_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ var _ = Describe("[sriov] operator", func() {
},
Spec: sriovv1.SriovNetworkSpec{
ResourceName: resourceName,
IPAM: `{"type":"host-local","subnet":"10.10.10.0/24","rangeStart":"10.10.10.171","rangeEnd":"10.10.10.181","routes":[{"dst":"0.0.0.0/0"}],"gateway":"10.10.10.1"}`,
IPAM: `{"type":"host-local","subnet":"10.10.10.0/24","rangeStart":"10.10.10.171","rangeEnd":"10.10.10.181}"`,
NetworkNamespace: namespaces.Test,
}}
err := clients.Create(context.Background(), sriovNetwork)
Expand Down Expand Up @@ -441,7 +441,7 @@ var _ = Describe("[sriov] operator", func() {
},
Spec: sriovv1.SriovNetworkSpec{
ResourceName: resourceName,
IPAM: `{"type":"host-local","subnet":"10.10.10.0/24","rangeStart":"10.10.10.171","rangeEnd":"10.10.10.181","routes":[{"dst":"0.0.0.0/0"}],"gateway":"10.10.10.1"}`,
IPAM: `{"type":"host-local","subnet":"10.10.10.0/24","rangeStart":"10.10.10.171","rangeEnd":"10.10.10.181"}`,
NetworkNamespace: namespaces.Test,
}}
err := clients.Create(context.Background(), sriovNetwork)
Expand Down Expand Up @@ -563,9 +563,7 @@ var _ = Describe("[sriov] operator", func() {
IPAM: `{"type":"host-local",
"subnet":"10.10.10.0/24",
"rangeStart":"10.10.10.171",
"rangeEnd":"10.10.10.181",
"routes":[{"dst":"0.0.0.0/0"}],
"gateway":"10.10.10.1"}`,
"rangeEnd":"10.10.10.181"}`,
NetworkNamespace: namespaces.Test,
}}

Expand Down Expand Up @@ -608,9 +606,7 @@ var _ = Describe("[sriov] operator", func() {
IPAM: `{"type":"host-local",
"subnet":"10.10.10.0/24",
"rangeStart":"10.10.10.171",
"rangeEnd":"10.10.10.181",
"routes":[{"dst":"0.0.0.0/0"}],
"gateway":"10.10.10.1"}`,
"rangeEnd":"10.10.10.181"}`,
NetworkNamespace: namespaces.Test,
}}

Expand Down Expand Up @@ -657,9 +653,7 @@ var _ = Describe("[sriov] operator", func() {
IPAM: `{"type":"host-local",
"subnet":"10.10.10.0/24",
"rangeStart":"10.10.10.171",
"rangeEnd":"10.10.10.181",
"routes":[{"dst":"0.0.0.0/0"}],
"gateway":"10.10.10.1"}`,
"rangeEnd":"10.10.10.181"}`,
NetworkNamespace: namespaces.Test,
}}

Expand Down Expand Up @@ -730,9 +724,7 @@ var _ = Describe("[sriov] operator", func() {
IPAM: `{"type":"host-local",
"subnet":"10.10.10.0/24",
"rangeStart":"10.10.10.171",
"rangeEnd":"10.10.10.181",
"routes":[{"dst":"0.0.0.0/0"}],
"gateway":"10.10.10.1"}`,
"rangeEnd":"10.10.10.181"}`,
MaxTxRate: &maxTxRate,
MinTxRate: &minTxRate,
NetworkNamespace: namespaces.Test,
Expand Down Expand Up @@ -766,9 +758,7 @@ var _ = Describe("[sriov] operator", func() {
IPAM: `{"type":"host-local",
"subnet":"10.10.10.0/24",
"rangeStart":"10.10.10.171",
"rangeEnd":"10.10.10.181",
"routes":[{"dst":"0.0.0.0/0"}],
"gateway":"10.10.10.1"}`,
"rangeEnd":"10.10.10.181"}`,
Vlan: 1,
VlanQoS: 2,
NetworkNamespace: namespaces.Test,
Expand Down Expand Up @@ -1310,7 +1300,7 @@ var _ = Describe("[sriov] operator", func() {
},
Spec: sriovv1.SriovNetworkSpec{
ResourceName: resourceName,
IPAM: `{"type":"host-local","subnet":"10.10.10.0/24","rangeStart":"10.10.10.171","rangeEnd":"10.10.10.181","routes":[{"dst":"0.0.0.0/0"}],"gateway":"10.10.10.1"}`,
IPAM: `{"type":"host-local","subnet":"10.10.10.0/24","rangeStart":"10.10.10.171","rangeEnd":"10.10.10.181"}`,
NetworkNamespace: namespaces.Test,
}}

Expand Down Expand Up @@ -1602,7 +1592,7 @@ var _ = Describe("[sriov] operator", func() {
},
Spec: sriovv1.SriovNetworkSpec{
ResourceName: resourceName,
IPAM: `{"type":"host-local","subnet":"10.10.10.0/24","rangeStart":"10.10.10.171","rangeEnd":"10.10.10.181","routes":[{"dst":"0.0.0.0/0"}],"gateway":"10.10.10.1"}`,
IPAM: `{"type":"host-local","subnet":"10.10.10.0/24","rangeStart":"10.10.10.171","rangeEnd":"10.10.10.181"}`,
NetworkNamespace: namespaces.Test,
}}

Expand Down

0 comments on commit 5cfd6d9

Please sign in to comment.