Skip to content

Commit 66bb485

Browse files
authored
Merge pull request #4799 from vincepri/delete-vpc-endpoint-cond
🐛 Delete VPC endpoints only if s3 bucket is enabled
2 parents c709216 + 27c8991 commit 66bb485

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

controllers/awscluster_controller_test.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,24 +1437,6 @@ func mockedDeleteVPCCallsForNonExistentVPC(m *mocks.MockEC2APIMockRecorder) {
14371437
}
14381438

14391439
func mockedDeleteVPCCalls(m *mocks.MockEC2APIMockRecorder) {
1440-
m.DescribeVpcEndpointsPages(gomock.Eq(&ec2.DescribeVpcEndpointsInput{
1441-
Filters: []*ec2.Filter{
1442-
{
1443-
Name: aws.String("vpc-id"),
1444-
Values: aws.StringSlice([]string{"vpc-exists"}),
1445-
},
1446-
}}),
1447-
gomock.Any()).Do(func(_, y interface{}) {
1448-
funct := y.(func(page *ec2.DescribeVpcEndpointsOutput, lastPage bool) bool)
1449-
funct(&ec2.DescribeVpcEndpointsOutput{VpcEndpoints: []*ec2.VpcEndpoint{{
1450-
VpcEndpointId: aws.String("vpce-12345"),
1451-
}}}, true)
1452-
}).Return(nil).AnyTimes()
1453-
1454-
m.DeleteVpcEndpoints(gomock.Eq(&ec2.DeleteVpcEndpointsInput{
1455-
VpcEndpointIds: aws.StringSlice([]string{"vpce-12345"}),
1456-
})).Return(&ec2.DeleteVpcEndpointsOutput{}, nil).AnyTimes()
1457-
14581440
m.DescribeSubnetsWithContext(context.TODO(), gomock.Eq(&ec2.DescribeSubnetsInput{
14591441
Filters: []*ec2.Filter{
14601442
{

pkg/cloud/services/network/vpc.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,15 @@ func (s *Service) deleteVPCEndpoints() error {
276276
return nil
277277
}
278278

279+
// Gather all services that might have been enabled.
280+
services := sets.New[string]()
281+
if s.scope.Bucket() != nil {
282+
services.Insert(fmt.Sprintf("com.amazonaws.%s.s3", s.scope.Region()))
283+
}
284+
if services.Len() == 0 {
285+
return nil
286+
}
287+
279288
// Get all existing endpoints.
280289
endpoints, err := s.describeVPCEndpoints()
281290
if err != nil {

0 commit comments

Comments
 (0)