Skip to content

Conversation

fiunchinho
Copy link
Contributor

What type of PR is this?

/kind bug

What this PR does / why we need it:

When trying to update a subnet tag that is already present on AWS to a different value, CAPA keeps reconciling the AWCluster forever, flapping between the different values of the tag. When reconciling the subnet tags this is what happens

  • AWSCluster has subnets, let's say subnet-1a2b3c has the tag customtag: 1
  • CAPA saves the tags to a local variable
  • CAPA overwrites all the subnet fields with the info from AWS, including tags. Let's say that the subnet in AWS contained customtag: 2 (different from the value in the AWSCluster CR)
  • CAPA takes the tags that it saved earlier to a local variable and it applies them to the AWS subnet. Now on AWS the subnet has the tag customtag: 1
  • At the end of the reconciliation, all the modifications to the AWSCluster CR are saved back to the k8s api. So the tag from AWS customtag: 2 is saved to the AWSCluster CR
  • CAPA reconciles again. It applies customtag: 2 to the subnet in AWS (because that's the value in the AWSCluster CR for this reconciliation), and it applies customtag: 1 to the AWSCluster CR (because that's the value in AWS)
  • Repeat ad infinitum

With the change on this PR, what we are doing is that the tags already present on AWS are not saved back to the AWSCluster.

Special notes for your reviewer:

Checklist:

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

Release note:

Don't overwrite subnet spec tags with tags from the subnet on AWS

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. labels Apr 22, 2025
@k8s-ci-robot k8s-ci-robot requested a review from cnmcavoy April 22, 2025 10:08
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 22, 2025
@k8s-ci-robot k8s-ci-robot requested a review from faiq April 22, 2025 10:08
@k8s-ci-robot k8s-ci-robot added needs-priority size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 22, 2025
@fiunchinho fiunchinho changed the title Don't overwrite subnet spec tags with AWS tags 🐛 Don't overwrite subnet spec tags with AWS tags Apr 22, 2025
@fiunchinho fiunchinho force-pushed the dont-overwrite-subnet-tags branch from 476a202 to b538673 Compare April 22, 2025 10:18
@fiunchinho fiunchinho force-pushed the dont-overwrite-subnet-tags branch from b538673 to bd953e3 Compare April 22, 2025 10:52
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 22, 2025
@fiunchinho
Copy link
Contributor Author

Pinging @mtulio as you were interested on the subnet tags in the past 🙂

@richardcase
Copy link
Member

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

@mtulio
Copy link
Contributor

mtulio commented Apr 24, 2025

Pinging @mtulio as you were interested on the subnet tags in the past 🙂

Hey @fiunchinho , Thanks for pinging! Good catch! Overall looks good to me. Do you think this scenario would be possible to reproduce in the tests?

Copy link
Contributor

@AndiDog AndiDog 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 Apr 24, 2025
@fiunchinho
Copy link
Contributor Author

Pinging @mtulio as you were interested on the subnet tags in the past 🙂

Hey @fiunchinho , Thanks for pinging! Good catch! Overall looks good to me. Do you think this scenario would be possible to reproduce in the tests?

I don't think there is any test currently that asserts behavior after running multiple reconciliations. This bug only surfaces when reconciling the same subnet several times. So I'm not really sure if we can easy test this, or if it's even worth it.

@mtulio
Copy link
Contributor

mtulio commented Apr 30, 2025

Pinging @mtulio as you were interested on the subnet tags in the past 🙂

Hey @fiunchinho , Thanks for pinging! Good catch! Overall looks good to me. Do you think this scenario would be possible to reproduce in the tests?

I don't think there is any test currently that asserts behavior after running multiple reconciliations. This bug only surfaces when reconciling the same subnet several times. So I'm not really sure if we can easy test this, or if it's even worth it.

/lgtm

@alexander-demicev
Copy link
Contributor

/lgtm

@damdo
Copy link
Member

damdo commented May 5, 2025

/assign @AndiDog @richardcase @nrb

for approval

@nrb
Copy link
Contributor

nrb commented May 5, 2025

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

@fiunchinho
Copy link
Contributor Author

/retest

@nrb
Copy link
Contributor

nrb commented May 5, 2025

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

@nrb
Copy link
Contributor

nrb commented May 6, 2025

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nrb

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

The pull request process is described 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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 6, 2025
@k8s-ci-robot k8s-ci-robot merged commit 2cf25eb into kubernetes-sigs:main May 6, 2025
20 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v2.8 milestone May 6, 2025
yongs2 pushed a commit to yongs2/cluster-api-provider-aws that referenced this pull request Jul 21, 2025
…e-subnet-tags

🐛 Don't overwrite subnet spec tags with AWS tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants