Skip to content

Commit

Permalink
remove validation of VPC CIDRs from ip rules (#1476)
Browse files Browse the repository at this point in the history
Recent changes in PR #1475 removes the VPC CIDR ranges from
the ip route rules. Modify the pod networking agent for compatibility
with the new changes introduced for symmetric return path.
  • Loading branch information
kishorj authored May 28, 2021
1 parent efc51f6 commit 66180f4
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions test/agent/cmd/networking/tester/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import (
"fmt"
"log"
"net"
"reflect"
"sort"
"strings"

"github.com/aws/amazon-vpc-cni-k8s/test/agent/pkg/input"
Expand All @@ -38,10 +36,6 @@ func TestNetworkingSetupForRegularPod(podNetworkingValidationInput input.PodNetw
log.Fatalf("failed to list ip rules %v", err)
}

// Sort the VPC CIDR Range as it will be compared with the
// IP Routes for Pods using Secondary ENI IPv4Address
sort.Strings(podNetworkingValidationInput.VPCCidrRange)

// Do validation for each Pod and if validation fails instead of failing
// entire test add errors to a list for all the failing Pods
var validationErrors []error
Expand Down Expand Up @@ -99,6 +93,7 @@ func TestNetworkingSetupForRegularPod(podNetworkingValidationInput input.PodNetw
nonMainTableRules = append(nonMainTableRules, rule)
}
}
log.Printf("mainTableRules %v, nonMainTableRules %v", mainTableRules, nonMainTableRules)

// Both Pod with IP from Primary and Secondary ENI will have 1 rule for main route table
if len(mainTableRules) != 1 {
Expand Down Expand Up @@ -141,21 +136,13 @@ func TestNetworkingSetupForRegularPod(podNetworkingValidationInput input.PodNetw
// Pod with IP from Secondary ENI will have additional rule for destination to each
// VPC Cidr block
if pod.IsIPFromSecondaryENI {
var destinationCidrRange []string
for _, rule := range nonMainTableRules {
destinationCidrRange = append(destinationCidrRange, rule.Dst.String())
// Add the secondary route table Index, we will do validation later
secondaryRouteTableIndex[rule.Table] = true
}
sort.Strings(destinationCidrRange)
// Validate there is one rule for each VPC CIDR Range
if !reflect.DeepEqual(destinationCidrRange, podNetworkingValidationInput.VPCCidrRange) {
if len(nonMainTableRules) != 1 {
validationErrors = append(validationErrors,
fmt.Errorf("failed to find route to vpc cidr: %v", destinationCidrRange))
continue
fmt.Errorf("incorrect number of ip rules to the secondary route tables: %+v",
nonMainTableRules))
} else {
secondaryRouteTableIndex[nonMainTableRules[0].Table] = true
}
log.Printf("validated all routes for VPC CIDR %v are present for secondary ENI",
destinationCidrRange)
}
log.Printf("validation for pod %s/%s succeeded", pod.PodNamespace, pod.PodName)
}
Expand Down Expand Up @@ -185,6 +172,7 @@ func TestNetworkingSetupForRegularPod(podNetworkingValidationInput input.PodNetw
}
log.Printf("validated route table for secondary ENI %d has right routes", index)
}
// TODO: validate iptables rules get setup correctly

return validationErrors
}
Expand Down

0 comments on commit 66180f4

Please sign in to comment.