@@ -47,9 +47,10 @@ var _ = Describe("ConnectionTracking", func() {
4747 instance := env .GetInstance (pod .Spec .NodeName )
4848 Expect (instance .NetworkInterfaces ).ToNot (BeEmpty ())
4949
50- primaryNI := instance .NetworkInterfaces [0 ]
51- Expect (primaryNI .Attachment ).ToNot (BeNil ())
52- Expect (aws .ToInt32 (primaryNI .Attachment .DeviceIndex )).To (Equal (int32 (0 )))
50+ primaryNI , found := lo .Find (instance .NetworkInterfaces , func (ni ec2types.InstanceNetworkInterface ) bool {
51+ return ni .Attachment != nil && ni .Attachment .DeviceIndex != nil && aws .ToInt32 (ni .Attachment .DeviceIndex ) == 0
52+ })
53+ Expect (found ).To (BeTrue ())
5354
5455 niOutput , err := env .EC2API .DescribeNetworkInterfaces (env .Context , & ec2.DescribeNetworkInterfacesInput {
5556 NetworkInterfaceIds : []string {aws .ToString (primaryNI .NetworkInterfaceId )},
@@ -143,7 +144,10 @@ var _ = Describe("ConnectionTracking", func() {
143144 instance := env .GetInstance (pod .Spec .NodeName )
144145 Expect (instance .NetworkInterfaces ).ToNot (BeEmpty ())
145146
146- primaryNI := instance .NetworkInterfaces [0 ]
147+ primaryNI , found := lo .Find (instance .NetworkInterfaces , func (ni ec2types.InstanceNetworkInterface ) bool {
148+ return ni .Attachment != nil && ni .Attachment .DeviceIndex != nil && aws .ToInt32 (ni .Attachment .DeviceIndex ) == 0
149+ })
150+ Expect (found ).To (BeTrue ())
147151 niOutput , err := env .EC2API .DescribeNetworkInterfaces (env .Context , & ec2.DescribeNetworkInterfacesInput {
148152 NetworkInterfaceIds : []string {aws .ToString (primaryNI .NetworkInterfaceId )},
149153 })
@@ -164,7 +168,10 @@ var _ = Describe("ConnectionTracking", func() {
164168 instance := env .GetInstance (pod .Spec .NodeName )
165169 Expect (instance .NetworkInterfaces ).ToNot (BeEmpty ())
166170
167- primaryNI := instance .NetworkInterfaces [0 ]
171+ primaryNI , found := lo .Find (instance .NetworkInterfaces , func (ni ec2types.InstanceNetworkInterface ) bool {
172+ return ni .Attachment != nil && ni .Attachment .DeviceIndex != nil && aws .ToInt32 (ni .Attachment .DeviceIndex ) == 0
173+ })
174+ Expect (found ).To (BeTrue ())
168175 niOutput , err := env .EC2API .DescribeNetworkInterfaces (env .Context , & ec2.DescribeNetworkInterfacesInput {
169176 NetworkInterfaceIds : []string {aws .ToString (primaryNI .NetworkInterfaceId )},
170177 })
0 commit comments