Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ feat: Remove owned VPCEs when deleting VPC. #5193

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions controllers/awscluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,18 @@ func mockedDeleteVPCCallsForNonExistentVPC(m *mocks.MockEC2APIMockRecorder) {
}

func mockedDeleteVPCCalls(m *mocks.MockEC2APIMockRecorder) {
m.DescribeVpcEndpointsPages(gomock.Eq(&ec2.DescribeVpcEndpointsInput{
Filters: []*ec2.Filter{
{
Name: aws.String("tag:sigs.k8s.io/cluster-api-provider-aws/cluster/test-cluster"),
Values: []*string{aws.String("owned")},
},
{
Name: aws.String("vpc-id"),
Values: []*string{aws.String("vpc-exists")},
},
},
}), gomock.Any()).Return(nil).AnyTimes()
m.DescribeSubnetsWithContext(context.TODO(), gomock.Eq(&ec2.DescribeSubnetsInput{
Filters: []*ec2.Filter{
{
Expand Down
11 changes: 1 addition & 10 deletions pkg/cloud/services/network/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,17 +276,8 @@ func (s *Service) deleteVPCEndpoints() error {
return nil
}

// Gather all services that might have been enabled.
services := sets.New[string]()
if s.scope.Bucket() != nil {
services.Insert(fmt.Sprintf("com.amazonaws.%s.s3", s.scope.Region()))
}
if services.Len() == 0 {
return nil
}

// Get all existing endpoints.
endpoints, err := s.describeVPCEndpoints()
endpoints, err := s.describeVPCEndpoints(filter.EC2.ClusterOwned(s.scope.Name()))
if err != nil {
return errors.Wrap(err, "failed to describe vpc endpoints")
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/data/e2e_eks_conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ intervals:
default/wait-machine-status: ["20m", "10s"]
default/wait-infra-subnets: ["5m", "30s"]
default/wait-control-plane-upgrade: ["35m", "30s"]
default/wait-addon-status: ["10m", "30s"]
default/wait-addon-status: ["30m", "30s"]
default/wait-create-identity: ["1m", "10s"]
default/wait-deployment-ready: ["5m", "10s"]
default/wait-loadbalancer-ready: ["5m", "30s"]
2 changes: 1 addition & 1 deletion test/e2e/shared/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func Node1BeforeSuite(e2eCtx *E2EContext) []byte {
success = false
}
return success
}, 10*time.Minute, 5*time.Second).Should(BeTrue(), "Should've eventually succeeded creating an AWS CloudFormation stack")
}, 45*time.Minute, 30*time.Second).Should(BeTrue(), "Should've eventually succeeded creating an AWS CloudFormation stack")
}

ensureStackTags(e2eCtx.AWSSession, bootstrapTemplate.Spec.StackName, bootstrapTags)
Expand Down
26 changes: 17 additions & 9 deletions test/e2e/suites/managed/eks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package managed
import (
"context"
"fmt"
"time"

"github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -76,15 +77,22 @@ var _ = ginkgo.Describe("[managed] [general] EKS cluster tests", func() {
})

ginkgo.By("should set environment variables on the aws-node daemonset")
CheckAwsNodeEnvVarsSet(ctx, func() UpdateAwsNodeVersionSpecInput {
return UpdateAwsNodeVersionSpecInput{
E2EConfig: e2eCtx.E2EConfig,
BootstrapClusterProxy: e2eCtx.Environment.BootstrapClusterProxy,
AWSSession: e2eCtx.BootstrapUserAWSSession,
Namespace: namespace,
ClusterName: clusterName,
}
})
Eventually(func() error {
defer ginkgo.GinkgoRecover()
CheckAwsNodeEnvVarsSet(ctx, func() UpdateAwsNodeVersionSpecInput {
return UpdateAwsNodeVersionSpecInput{
E2EConfig: e2eCtx.E2EConfig,
BootstrapClusterProxy: e2eCtx.Environment.BootstrapClusterProxy,
AWSSession: e2eCtx.BootstrapUserAWSSession,
Namespace: namespace,
ClusterName: clusterName,
}
})
return nil
}).WithTimeout(5*time.Minute).WithPolling(10*time.Second).WithContext(ctx).Should(
Succeed(),
"Failed to verify AWS Node environment variables after 5 minutes of retries",
)

ginkgo.By("should have the VPC CNI installed")
CheckAddonExistsSpec(ctx, func() CheckAddonExistsSpecInput {
Expand Down