Skip to content

Commit

Permalink
Merge pull request #7483 from Emberwalker/public-endpoint-cidrs-unord…
Browse files Browse the repository at this point in the history
…ered

Handle unordered public endpoint CIDRs from EKS in endpoint updates
  • Loading branch information
yuxiang-zhang authored Jan 19, 2024
2 parents 002ce9a + 99593da commit 054a558
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/ctl/utils/vpc_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/kris-nova/logger"
"k8s.io/apimachinery/pkg/util/sets"

"golang.org/x/exp/slices"

Expand Down Expand Up @@ -176,5 +177,6 @@ func cidrsEqual(currentValues, newValues []string) bool {
if len(newValues) == 0 && len(currentValues) == 1 && currentValues[0] == "0.0.0.0/0" {
return true
}
return slices.Equal(currentValues, newValues)

return sets.NewString(currentValues...).Equal(sets.NewString(newValues...))
}
15 changes: 15 additions & 0 deletions pkg/ctl/utils/vpc_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,21 @@ var _ = DescribeTable("VPCHelper", func(e vpcHelperEntry) {
},
}),

Entry("cluster public access CIDRs match desired config but out of order", vpcHelperEntry{
clusterVPC: &ekstypes.VpcConfigResponse{
EndpointPublicAccess: true,
EndpointPrivateAccess: false,
PublicAccessCidrs: []string{"2.2.2.2/32", "1.1.1.1/32"},
},
vpc: &api.ClusterVPC{
ClusterEndpoints: &api.ClusterEndpoints{
PublicAccess: api.Enabled(),
PrivateAccess: api.Disabled(),
},
PublicAccessCIDRs: []string{"1.1.1.1/32", "2.2.2.2/32"},
},
}),

Entry("both cluster endpoint access and public access CIDRs do not match desired config", vpcHelperEntry{
clusterVPC: &ekstypes.VpcConfigResponse{
EndpointPublicAccess: true,
Expand Down

0 comments on commit 054a558

Please sign in to comment.