Skip to content

🌱 Migrate gc to aws sdk v2 #5518

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Danil-Grigorev
Copy link
Member

@Danil-Grigorev Danil-Grigorev commented Jun 3, 2025

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Migrate ELB garbage collection to AWS SDK v2

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #5406

Special notes for your reviewer:

Checklist:

  • squashed commits
  • includes documentation
  • includes emoji in title
  • adds unit tests
  • adds or updates e2e tests

Release note:

Migrate ELB garbage collection to AWS SDK v2

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/support Categorizes issue or PR as a support question. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 3, 2025
@k8s-ci-robot k8s-ci-robot added needs-priority needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jun 3, 2025
@Danil-Grigorev Danil-Grigorev force-pushed the migrate-gc-to-aws-sdk-v2 branch from 7b8080f to 1822ed1 Compare June 3, 2025 19:05
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 3, 2025
@Danil-Grigorev Danil-Grigorev force-pushed the migrate-gc-to-aws-sdk-v2 branch from 1822ed1 to adc451e Compare June 3, 2025 19:06
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 3, 2025
@Danil-Grigorev Danil-Grigorev force-pushed the migrate-gc-to-aws-sdk-v2 branch from a75be30 to b39b276 Compare June 4, 2025 06:31
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 4, 2025
@Danil-Grigorev Danil-Grigorev changed the title [WIP] Migrate gc to aws sdk v2 🌱 Migrate gc to aws sdk v2 Jun 4, 2025
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jun 4, 2025
@Danil-Grigorev Danil-Grigorev force-pushed the migrate-gc-to-aws-sdk-v2 branch 5 times, most recently from fccf39b to 12a5c0a Compare June 4, 2025 07:04
@Danil-Grigorev
Copy link
Member Author

/test pull-cluster-api-provider-aws-e2e
/test pull-cluster-api-provider-aws-e2e-eks
/kind cleanup

@k8s-ci-robot k8s-ci-robot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Jun 4, 2025
@Danil-Grigorev Danil-Grigorev force-pushed the migrate-gc-to-aws-sdk-v2 branch from 12a5c0a to 2cfd1e6 Compare June 4, 2025 08:28
@damdo
Copy link
Member

damdo commented Jun 4, 2025

/assign @nrb

@nrb
Copy link
Contributor

nrb commented Jun 25, 2025

Merging another PR unfortunately introduced some conflicts on this one. Also, the copyright for brand new files should be the current year.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 25, 2025
Migrate the garbage collection service and related components to use the AWS SDK v2.
This involves updating dependencies, refactoring client initialization, and updating API calls within the GC logic.
Adds new v2 specific converters, filters, and mocks.

Migrate the garbage collection logic for AWS Application Load Balancers (ALBs) and Network Load Balancers (NLBs) to use the AWS SDK v2.

Migrate the garbage collection logic for Classic Load Balancers (ELB) from the AWS SDK v1 to v2.

Signed-off-by: Danil-Grigorev <[email protected]>
@Danil-Grigorev Danil-Grigorev force-pushed the migrate-gc-to-aws-sdk-v2 branch from e991120 to 13f92c2 Compare June 26, 2025 09:10
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from andidog. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 26, 2025
@damdo
Copy link
Member

damdo commented Jun 26, 2025

@alexander-demicev would you be able to have a second look and re-add your LGTM if you are happy with it?
Thanks!

Copy link
Contributor

@alexander-demicev alexander-demicev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 26, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: cef4df8dd78cc2740930f3275f6bb2f33d481ebf

@alexander-demicev
Copy link
Contributor

/test pull-cluster-api-provider-aws-e2e
/test pull-cluster-api-provider-aws-e2e-eks

@damdo damdo requested a review from nrb June 26, 2025 10:14
@damdo
Copy link
Member

damdo commented Jun 26, 2025

/hold

for testing to pass

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 26, 2025
ResourceTagging resourcegroupstaggingapiiface.ResourceGroupsTaggingAPIAPI
ASG autoscaling.Client
EC2 ec2iface.EC2API
ELB elbiface.ELBAPI
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we not be adding the ELBv2 interface here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not used anywhere in the updated code as far as I can recall, and to keep changes slim I didn’t add it here. Do you think this needs to be a part of the PR?

@damdo damdo requested a review from richardcase June 26, 2025 14:39
@@ -606,7 +606,7 @@ promote-images: $(KPROMO) $(YQ)

.PHONY: release-binaries
release-binaries: $(GORELEASER) ## Builds only the binaries, not a release.
$(GORELEASER) build --config $(GORELEASER_CONFIG) --snapshot --clean
GOMAXPROCS=2 $(GORELEASER) build --config $(GORELEASER_CONFIG) --snapshot --clean
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change is unrelated – can we take this out?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think so, this change fixes stuck goreleaser build in CI: #5518 (comment) I was able to reproduce it locally, and this change fixes it. Some other AWS SDK v2 rewrite PRs are affected by this too.

*/

// Package filterv2 contains the ec2 sdk v2 related filters.
package filterv2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you refer to filterv2 in general, it is needed and used for example in https://github.com/kubernetes-sigs/cluster-api-provider-aws/pull/5518/files#diff-fb7618ec3e9301951d4d093fa53e72a5f8ee1ef919d4213dcf6f530125f800ecR29 I simply copied filter package, the types.go there is empty as well.

{
Key: aws.String("kubernetes.io/cluster/cluster1"),
Key: aws.String("kubernetes.io/cluster/eks-test-cluster"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does the cluster name need to be changed in this test?

@@ -80,7 +80,8 @@ func (s *Service) deleteTargetGroups(ctx context.Context, resources []*AWSResour
}

func (s *Service) isELBResourceToDelete(resource *AWSResource, resourceName string) bool {
if !s.isMatchingResource(resource, elb.ServiceName, resourceName) {
// Need to update this to use the v2 service name if it's different
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a TODO? It's unclear what needs to be done / what's left to do. Which v2 (ELBv2 or AWS SDK Go v2), ...?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

V2 packages stopped using ServiceName variables. I think this can be removed though.

@@ -134,14 +135,17 @@ func (s *Service) deleteTargetGroup(ctx context.Context, targetGroupARN string)
// describeLoadBalancers gets all elastic LBs.
func (s *Service) describeLoadBalancers(ctx context.Context) ([]string, error) {
var names []string
err := s.elbClient.DescribeLoadBalancersPagesWithContext(ctx, &elb.DescribeLoadBalancersInput{}, func(r *elb.DescribeLoadBalancersOutput, last bool) bool {
for _, lb := range r.LoadBalancerDescriptions {
// AWS SDK v2 does not have PagesWithContext, need to use paginator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment can be removed since we get the context timeout functionality via NextPage(ctx)

@Danil-Grigorev Danil-Grigorev force-pushed the migrate-gc-to-aws-sdk-v2 branch from c2c6a4d to 5012b2c Compare June 27, 2025 11:10
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 27, 2025
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@Danil-Grigorev Danil-Grigorev force-pushed the migrate-gc-to-aws-sdk-v2 branch from 5012b2c to 8ee8a1e Compare June 27, 2025 11:27
@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Jun 27, 2025

@Danil-Grigorev: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cluster-api-provider-aws-e2e c2c6a4d link false /test pull-cluster-api-provider-aws-e2e
pull-cluster-api-provider-aws-apidiff-main 8ee8a1e link false /test pull-cluster-api-provider-aws-apidiff-main

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/support Categorizes issue or PR as a support question. needs-priority release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate gc code to AWS SDK v2
9 participants