Skip to content

feat(tags): filter AWS tags and ACK tags during reconciliation #170

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

Merged
merged 2 commits into from
Feb 17, 2025

Conversation

michaelhtm
Copy link
Member

@michaelhtm michaelhtm commented Feb 10, 2025

Issue #2248

Description of changes:
When we adopt ACK resources, if those resources are injected by AWS,
we are trying to avoid from patching them into the resource.
For this reason we are adding two new methods for the AWSResourceManager
interface.

MirrowAWSTags:
This method ensures the AWS tags returned by the API after a read
operation are mirrored in the desired resource. Mirroring the tags in the desired
makes them undetected by the controller.

New FilterSystemTags Function:
Removes System tags injected by AWS (cloudformation aws:)
or the controller (services.k8s.aws). This method is called during
adoption, to ensure these tags are not patched into the controller.


Also removing EnsureTag operations during adoption to avoid ACK from patching controller tags
to the resource.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link

ack-prow bot commented Feb 10, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ack-prow ack-prow bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 10, 2025
@ack-prow ack-prow bot requested review from a-hilaly and jlbutler February 10, 2025 22:11
@michaelhtm michaelhtm marked this pull request as ready for review February 10, 2025 23:25
@ack-prow ack-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 10, 2025
@michaelhtm michaelhtm force-pushed the adress/tag-issue branch 2 times, most recently from 2b71b27 to 795a5e1 Compare February 13, 2025 02:08
Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

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

Thank you @michaelhtm ! left a few comments in-line

Add utility to automatically preserve immutable AWS-managed tags (aws:*)
when modifying resources. Prevents tag operation errors with
CloudFormation and Service Catalog managed resources.
@michaelhtm michaelhtm changed the title Add IgnoreAWSTags, remove EnsureTags for adoption feat(tags): add SyncAWSTags for AWS-managed tag preservation Feb 14, 2025
@michaelhtm michaelhtm changed the title feat(tags): add SyncAWSTags for AWS-managed tag preservation feat(tags): add MirrorAWSTags and FilterSystemTags methods Feb 14, 2025
@michaelhtm michaelhtm changed the title feat(tags): add MirrorAWSTags and FilterSystemTags methods feat(tags): filter AWS tags and ACK tags during reconciliation Feb 14, 2025
@michaelhtm michaelhtm force-pushed the adress/tag-issue branch 2 times, most recently from 65a917f to 9868c97 Compare February 15, 2025 00:03
This funtion will filter out tags injected by AWS and ACK.
Copy link

ack-prow bot commented Feb 15, 2025

@michaelhtm: 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
verify-attribution 2748a4e link false /test verify-attribution
iam-controller-test 2748a4e link true /test iam-controller-test
ecr-controller-test 2748a4e link true /test ecr-controller-test
s3-controller-test 2748a4e link true /test s3-controller-test

Full PR test history. Your PR dashboard.

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/test-infra repository. I understand the commands that are listed here.

Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

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

👍

Copy link

ack-prow bot commented Feb 17, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: a-hilaly, michaelhtm

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

@ack-prow ack-prow bot added the approved label Feb 17, 2025
@a-hilaly a-hilaly merged commit 5b918f9 into aws-controllers-k8s:main Feb 17, 2025
1 of 6 checks passed
michaelhtm added a commit to michaelhtm/ack-code-generator that referenced this pull request Mar 6, 2025
When converting between ACK tags (map[string]string) and
resource tags(which could be either a list of Tag struct or map[string]*string)
can be tricky. One issue that we found was order preservation, especially when
converting from `map[string]string` to list of `Tag`.  The changed order, when
patched to the resource in the cluster, would trigger a reconciliation, for an
unpredictable amount of times (at least until we luckily convert to the list with
a preserved order.)

This change introduces two new functions, similar to the existing ones.

The `toACKTagsWithKeyOrder` has the same function as `ToACKTags`,
but besides returning the ACK tags, it also returns a list of keys in the same
order it is in the resource.

The `fromACKTagsWithKeyOrder`, also similar to `FromACKTags`, accepts
the keyOrder returned by `toACKTagsWithKeyOrder`, and rebuilds the resource
tags, if it's a list, in the same order as it was before. Any extra tags will be added
in random order.

These two new functions will be called before and after `mirrowAWSTags` and
`FilterSystemTags`. The extra tags mentioned earlier are the AWS tags that are
mirrored from the latest resource (more explanation on what they are [here](aws-controllers-k8s/runtime#170)) and will be filtered before getting patched with [this](aws-controllers-k8s/runtime#172)
change.
This will ensure that the tags in desired will maintain their order and avoid triggering
unnecessary reconciliations.
michaelhtm added a commit to michaelhtm/ack-code-generator that referenced this pull request Mar 6, 2025
When converting between ACK tags (map[string]string) and
resource tags(which could be either a list of Tag struct or map[string]*string)
can be tricky. One issue that we found was order preservation, especially when
converting from `map[string]string` to list of `Tag`.  The changed order, when
patched to the resource in the cluster, would trigger a reconciliation, for an
unpredictable amount of times (at least until we luckily convert to the list with
a preserved order.)

This change introduces two new functions, similar to the existing ones.

The `toACKTagsWithKeyOrder` has the same function as `ToACKTags`,
but besides returning the ACK tags, it also returns a list of keys in the same
order it is in the resource.

The `fromACKTagsWithKeyOrder`, also similar to `FromACKTags`, accepts
the keyOrder returned by `toACKTagsWithKeyOrder`, and rebuilds the resource
tags, if it's a list, in the same order as it was before. Any extra tags will be added
in random order.

These two new functions will be called before and after `mirrowAWSTags` and
`FilterSystemTags`. The extra tags mentioned earlier are the AWS tags that are
mirrored from the latest resource (more explanation on what they are [here](aws-controllers-k8s/runtime#170)) and will be filtered before getting patched with [this](aws-controllers-k8s/runtime#172)
change.
This will ensure that the tags in desired will maintain their order and avoid triggering
unnecessary reconciliations.
michaelhtm added a commit to michaelhtm/ack-code-generator that referenced this pull request Mar 7, 2025
When converting between ACK tags (map[string]string) and
resource tags(which could be either a list of Tag struct or map[string]*string)
can be tricky. One issue that we found was order preservation, especially when
converting from `map[string]string` to list of `Tag`.  The changed order, when
patched to the resource in the cluster, would trigger a reconciliation, for an
unpredictable amount of times (at least until we luckily convert to the list with
a preserved order.)

This change introduces two new functions, similar to the existing ones.

The `toACKTagsWithKeyOrder` has the same function as `ToACKTags`,
but besides returning the ACK tags, it also returns a list of keys in the same
order it is in the resource.

The `fromACKTagsWithKeyOrder`, also similar to `FromACKTags`, accepts
the keyOrder returned by `toACKTagsWithKeyOrder`, and rebuilds the resource
tags, if it's a list, in the same order as it was before. Any extra tags will be added
in random order.

These two new functions will be called before and after `mirrowAWSTags` and
`FilterSystemTags`. The extra tags mentioned earlier are the AWS tags that are
mirrored from the latest resource (more explanation on what they are [here](aws-controllers-k8s/runtime#170)) and will be filtered before getting patched with [this](aws-controllers-k8s/runtime#172)
change.
This will ensure that the tags in desired will maintain their order and avoid triggering
unnecessary reconciliations.
ack-prow bot pushed a commit to aws-controllers-k8s/code-generator that referenced this pull request Mar 10, 2025
…#572)

Description of changes:
When converting between ACK tags (map[string]string) and 
resource tags(which could be either a list of Tag struct or map[string]*string)
can be tricky. One issue that we found was order preservation, especially when 
converting from `map[string]string` to list of `Tag`.  The changed order, when 
patched to the resource in the cluster, would trigger a reconciliation, for an
unpredictable amount of times (at least until we luckily convert to the list with
a preserved order.)

This change introduces two new functions, similar to the existing ones.

The `toACKTagsWithKeyOrder` has the same function as `ToACKTags`,
but besides returning the ACK tags, it also returns a list of keys in the same
order it is in the resource.

The `fromACKTagsWithKeyOrder`, also similar to `FromACKTags`, accepts
the keyOrder returned by `toACKTagsWithKeyOrder`, and rebuilds the resource
tags, if it's a list, in the same order as it was before. Any extra tags will be added
in random order.

These two new functions will be called before and after `mirrowAWSTags` and
`FilterSystemTags`. The extra tags mentioned earlier are the AWS tags that are 
mirrored from the latest resource (more explanation on what they are [here](aws-controllers-k8s/runtime#170)) and will be filtered before getting patched with [this](aws-controllers-k8s/runtime#172)
change.
This will ensure that the tags in desired will maintain their order and avoid triggering
unnecessary reconciliations.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants