Skip to content

Commit b6eda5c

Browse files
committed
Fix subnet sorting with multiple vpcs when launching an instance
Signed-off-by: Cameron McAvoy <[email protected]>
1 parent 181bdc9 commit b6eda5c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/cloud/services/ec2/instances.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,10 @@ func (s *Service) findSubnet(scope *scope.MachineScope) (string, error) {
370370

371371
filtered = append(filtered, subnet)
372372
}
373-
// prefer a subnet in the cluster VPC if multiple match
373+
// keep AWS returned orderz stable, but prefer a subnet in the cluster VPC
374374
clusterVPC := s.scope.VPC().ID
375375
sort.SliceStable(filtered, func(i, j int) bool {
376-
return strings.Compare(*filtered[i].VpcId, clusterVPC) > strings.Compare(*filtered[j].VpcId, clusterVPC)
376+
return *filtered[i].VpcId == clusterVPC
377377
})
378378
if len(filtered) == 0 {
379379
errMessage = fmt.Sprintf("failed to run machine %q, found %d subnets matching criteria but post-filtering failed.",

0 commit comments

Comments
 (0)