Skip to content

Commit

Permalink
Fix the AZ name to AZ ID mapping in tests. (#2766)
Browse files Browse the repository at this point in the history
Don't rely on node index, which is an independent entity.
  • Loading branch information
orsenthil authored Jan 26, 2024
1 parent 8f56a1a commit aed881c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test/integration/cni/pod_traffic_across_az_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ var _ = Describe("[STATIC_CANARY] test pod networking", FlakeAttempts(retries),
})
})

// Functio to Az to Pod mapping and Az to AZ ID mapping
// Function for AZ to Pod mapping and AZ to AZ ID mapping
func GetAZMappings(nodes coreV1.NodeList) (map[string]coreV1.Pod, map[string]string) {
// Map of AZ name to Pod from Daemonset running on nodes
azToPod := make(map[string]coreV1.Pod)
Expand All @@ -150,6 +150,11 @@ func GetAZMappings(nodes coreV1.NodeList) (map[string]coreV1.Pod, map[string]str

describeAZOutput, err := f.CloudServices.EC2().DescribeAvailabilityZones()

// iterate describe AZ output and populate AZ name to AZ ID mapping
for _, az := range describeAZOutput.AvailabilityZones {
azToazID[*az.ZoneName] = *az.ZoneId
}

if err != nil {
// Don't fail the test if we can't describe AZs. The failure will be caught by the test
// We use describe AZs to get the AZ ID for metrics.
Expand All @@ -170,7 +175,6 @@ func GetAZMappings(nodes coreV1.NodeList) (map[string]coreV1.Pod, map[string]str
azToPod[azName] = interfaceToPodList.PodsOnPrimaryENI[0]
}

azToazID[azName] = *describeAZOutput.AvailabilityZones[i].ZoneId
}
return azToPod, azToazID
}
Expand Down

0 comments on commit aed881c

Please sign in to comment.