@@ -17,12 +17,11 @@ import (
17
17
"strconv"
18
18
"time"
19
19
20
- v1 "k8s.io/api/core/v1"
21
-
22
20
"github.com/aws/amazon-vpc-cni-k8s/test/framework/resources/k8s/manifest"
23
21
k8sUtils "github.com/aws/amazon-vpc-cni-k8s/test/framework/resources/k8s/utils"
24
22
"github.com/aws/amazon-vpc-cni-k8s/test/framework/utils"
25
23
"github.com/aws/amazon-vpc-cni-k8s/test/integration/common"
24
+ v1 "k8s.io/api/core/v1"
26
25
27
26
. "github.com/onsi/ginkgo/v2"
28
27
. "github.com/onsi/gomega"
@@ -31,13 +30,15 @@ import (
31
30
// TODO: Instead of passing the list of pods to the test helper, have the test helper get the pod on node
32
31
const (
33
32
NEW_MTU_VAL = 1300
33
+ NEW_POD_MTU = 1280
34
34
NEW_VETH_PREFIX = "veth"
35
+ podLabelKey = "app"
36
+ podLabelVal = "host-networking-test"
35
37
)
36
38
39
+ var err error
40
+
37
41
var _ = Describe ("test host networking" , func () {
38
- var err error
39
- var podLabelKey = "app"
40
- var podLabelVal = "host-networking-test"
41
42
42
43
// For host networking tests, increase WARM_IP_TARGET to prevent long IPAMD warmup.
43
44
BeforeEach (func () {
@@ -57,6 +58,10 @@ var _ = Describe("test host networking", func() {
57
58
"AWS_VPC_ENI_MTU" : DEFAULT_MTU_VAL ,
58
59
"AWS_VPC_K8S_CNI_VETHPREFIX" : DEFAULT_VETH_PREFIX ,
59
60
})
61
+ k8sUtils .RemoveVarFromDaemonSetAndWaitTillUpdated (f , utils .AwsNodeName ,
62
+ utils .AwsNodeNamespace , utils .AwsNodeName , map [string ]struct {}{
63
+ "POD_MTU" : {},
64
+ })
60
65
// After updating daemonset pod, we must wait until conflist is updated so that container-runtime calls CNI ADD with the latest VETH prefix and MTU.
61
66
// Otherwise, the stale value can cause failures in future test cases.
62
67
time .Sleep (utils .PollIntervalMedium )
@@ -104,51 +109,13 @@ var _ = Describe("test host networking", func() {
104
109
common .ValidateHostNetworking (common .NetworkingTearDownSucceeds , input , primaryNode .Name , f )
105
110
})
106
111
107
- It ("Validate Host Networking setup after changing MTU and Veth Prefix" , func () {
108
- deployment := manifest .NewBusyBoxDeploymentBuilder (f .Options .TestImageRegistry ).
109
- Replicas (maxIPPerInterface * 2 ).
110
- PodLabel (podLabelKey , podLabelVal ).
111
- NodeName (primaryNode .Name ).
112
- Build ()
113
-
114
- By ("Configuring Veth Prefix and MTU value on aws-node daemonset" )
115
- k8sUtils .AddEnvVarToDaemonSetAndWaitTillUpdated (f , utils .AwsNodeName , utils .AwsNodeNamespace , utils .AwsNodeName , map [string ]string {
116
- "AWS_VPC_ENI_MTU" : strconv .Itoa (NEW_MTU_VAL ),
117
- "AWS_VPC_K8S_CNI_VETHPREFIX" : NEW_VETH_PREFIX ,
112
+ Context ("Validate Host Networking setup after changing Veth Prefix and" , func () {
113
+ It ("ENI MTU" , func () {
114
+ mtuValidationTest (false , NEW_MTU_VAL )
115
+ })
116
+ It ("POD MTU" , func () {
117
+ mtuValidationTest (true , NEW_POD_MTU )
118
118
})
119
- // After updating daemonset pod, we must wait until conflist is updated so that container-runtime calls CNI ADD with the new VETH prefix and MTU.
120
- time .Sleep (utils .PollIntervalMedium )
121
-
122
- By ("creating a deployment to launch pods" )
123
- deployment , err = f .K8sResourceManagers .DeploymentManager ().
124
- CreateAndWaitTillDeploymentIsReady (deployment , utils .DefaultDeploymentReadyTimeout )
125
- Expect (err ).ToNot (HaveOccurred ())
126
-
127
- By ("getting the list of pods using IP from primary and secondary ENI" )
128
- interfaceTypeToPodList :=
129
- common .GetPodsOnPrimaryAndSecondaryInterface (primaryNode , podLabelKey , podLabelVal , f )
130
-
131
- By ("generating the pod networking validation input to be passed to tester" )
132
- podNetworkingValidationInput := common .GetPodNetworkingValidationInput (interfaceTypeToPodList , vpcCIDRs )
133
- podNetworkingValidationInput .VethPrefix = NEW_VETH_PREFIX
134
- podNetworkingValidationInput .ValidateMTU = true
135
- podNetworkingValidationInput .MTU = NEW_MTU_VAL
136
- input , err := podNetworkingValidationInput .Serialize ()
137
- Expect (err ).NotTo (HaveOccurred ())
138
-
139
- By ("validating host networking setup is setup correctly with MTU check as well" )
140
- common .ValidateHostNetworking (common .NetworkingSetupSucceeds , input , primaryNode .Name , f )
141
-
142
- By ("deleting the deployment to test teardown" )
143
- err = f .K8sResourceManagers .DeploymentManager ().
144
- DeleteAndWaitTillDeploymentIsDeleted (deployment )
145
- Expect (err ).ToNot (HaveOccurred ())
146
-
147
- By ("waiting to allow CNI to tear down networking for terminated pods" )
148
- time .Sleep (time .Second * 60 )
149
-
150
- By ("validating host networking is teared down correctly" )
151
- common .ValidateHostNetworking (common .NetworkingTearDownSucceeds , input , primaryNode .Name , f )
152
119
})
153
120
})
154
121
@@ -205,3 +172,59 @@ var _ = Describe("test host networking", func() {
205
172
})
206
173
})
207
174
})
175
+
176
+ func mtuValidationTest (usePodMTU bool , mtuVal int ) {
177
+ deployment := manifest .NewBusyBoxDeploymentBuilder (f .Options .TestImageRegistry ).
178
+ Replicas (maxIPPerInterface * 2 ).
179
+ PodLabel (podLabelKey , podLabelVal ).
180
+ NodeName (primaryNode .Name ).
181
+ Build ()
182
+
183
+ if usePodMTU {
184
+ By ("Configuring Veth Prefix and Pod MTU value on aws-node daemonset" )
185
+ k8sUtils .AddEnvVarToDaemonSetAndWaitTillUpdated (f , utils .AwsNodeName , utils .AwsNodeNamespace , utils .AwsNodeName , map [string ]string {
186
+ "AWS_VPC_ENI_MTU" : strconv .Itoa (NEW_MTU_VAL ),
187
+ "POD_MTU" : strconv .Itoa (NEW_POD_MTU ),
188
+ "AWS_VPC_K8S_CNI_VETHPREFIX" : NEW_VETH_PREFIX ,
189
+ })
190
+ } else {
191
+ By ("Configuring Veth Prefix and ENI MTU value on aws-node daemonset" )
192
+ k8sUtils .AddEnvVarToDaemonSetAndWaitTillUpdated (f , utils .AwsNodeName , utils .AwsNodeNamespace , utils .AwsNodeName , map [string ]string {
193
+ "AWS_VPC_ENI_MTU" : strconv .Itoa (NEW_MTU_VAL ),
194
+ "AWS_VPC_K8S_CNI_VETHPREFIX" : NEW_VETH_PREFIX ,
195
+ })
196
+ }
197
+ // After updating daemonset pod, we must wait until conflist is updated so that container-runtime calls CNI ADD with the new VETH prefix and MTU.
198
+ time .Sleep (utils .PollIntervalMedium )
199
+
200
+ By ("creating a deployment to launch pods" )
201
+ deployment , err = f .K8sResourceManagers .DeploymentManager ().
202
+ CreateAndWaitTillDeploymentIsReady (deployment , utils .DefaultDeploymentReadyTimeout )
203
+ Expect (err ).ToNot (HaveOccurred ())
204
+
205
+ By ("getting the list of pods using IP from primary and secondary ENI" )
206
+ interfaceTypeToPodList :=
207
+ common .GetPodsOnPrimaryAndSecondaryInterface (primaryNode , podLabelKey , podLabelVal , f )
208
+
209
+ By ("generating the pod networking validation input to be passed to tester" )
210
+ podNetworkingValidationInput := common .GetPodNetworkingValidationInput (interfaceTypeToPodList , vpcCIDRs )
211
+ podNetworkingValidationInput .VethPrefix = NEW_VETH_PREFIX
212
+ podNetworkingValidationInput .ValidateMTU = true
213
+ podNetworkingValidationInput .MTU = mtuVal
214
+ input , err := podNetworkingValidationInput .Serialize ()
215
+ Expect (err ).NotTo (HaveOccurred ())
216
+
217
+ By ("validating host networking setup is setup correctly with MTU check as well" )
218
+ common .ValidateHostNetworking (common .NetworkingSetupSucceeds , input , primaryNode .Name , f )
219
+
220
+ By ("deleting the deployment to test teardown" )
221
+ err = f .K8sResourceManagers .DeploymentManager ().
222
+ DeleteAndWaitTillDeploymentIsDeleted (deployment )
223
+ Expect (err ).ToNot (HaveOccurred ())
224
+
225
+ By ("waiting to allow CNI to tear down networking for terminated pods" )
226
+ time .Sleep (time .Second * 60 )
227
+
228
+ By ("validating host networking is teared down correctly" )
229
+ common .ValidateHostNetworking (common .NetworkingTearDownSucceeds , input , primaryNode .Name , f )
230
+ }
0 commit comments