-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Bugfix/eventbridge/process to all matching rules #12090
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
Bugfix/eventbridge/process to all matching rules #12090
Conversation
c81a784
to
718f429
Compare
LocalStack Community integration with Pro 2 files ± 0 2 suites ±0 1h 7m 15s ⏱️ - 45m 52s Results for commit a91d8fc. ± Comparison against base commit 3e1471a. This pull request removes 1555 and adds 9 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! This does fix the issue, and adds quite a big (massive!) amount of tests! It should not break persistence either because this is done manually when restoring.
I have a nit concerning deleting the target senders when deleting rules and event buses, but this can be tackled in a follow up, as it's not exactly the scope of this PR and was already an issue before.
Thanks a lot for fixing this! 💯
snapshot.add_transformers_list( | ||
[ | ||
snapshot.transform.regex(target_id, "target-id"), | ||
snapshot.transform.regex(queue_arn, "target-arn"), | ||
] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think it'd be better to use key_value
transformers here in order to have the reference counting, but it also work that way, just less explicit
@@ -1835,11 +1835,11 @@ def _delete_rule_services(self, rules: RuleDict | Rule) -> None: | |||
def _delete_target_sender(self, ids: TargetIdList, rule) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see this is only used when deleting targets. However, from everything I can see in this PR, Targets
are living inside a Rule
. Shouldn't we delete all TargetSender
when deleting a rule? As we're caching the clients inside the sender, it could lead to quite some memory being taken and never released.
I think that we should delete all the TargetSender
when deleting a rule. This is somewhat outside of the scope of this PR, but also somewhat in it, because you chose to go the "nested" route in the dictionary key, when in reality, it seems the structure is more rule_arn
-> target_id
-> TargetSender
for the dict (self._target_sender_store[rule_arn][target_id]
), so it should have another level of nesting, so that when you delete the rule
, you can do del self._target_sender_store[rule_arn]
instead of having to iterate over all target and create the "nested key" every time. Both works, you just need to manipulate the key every time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I like your approach for nesting targets under rules. Regarding deleting them - aws does not allow the deleting of a rule that still has targets - first all targets must be manually deleted - this takes care of the above-mentioned problem.
Co-authored-by: Ben Simon Hartung <42031100+bentsku@users.noreply.github.com>
Co-authored-by: Ben Simon Hartung <42031100+bentsku@users.noreply.github.com>
Motivation
Internally target_services are stored in a dictionary _target_servuce_store and identified via the target_arn, this leads to problems since the target_arn is not unique for targets globally and across rules.
The target_id is unique across targets for a single rule, thus a globally unique id is a combination of rule_arn and target_id
This problem also solves the following github bug report: #11335
Changes
Changing the key for _target_servuce_store to
rule_arn-target_id
Testing
Adding test for multiple rules with single or multiple patterns invoking the same target.
Adding tests for uniqueness of target_id across targets of single rule and across multiple rules
Adding tests for uniqueness of target_arn across targets of single rule and across multiple rules