-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Sns/v2 apply subscribe changes #13226
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
Conversation
Test Results - Preflight, Unit22 337 tests +45 20 587 ✅ +38 15m 35s ⏱️ -1s Results for commit 8a097e6. ± Comparison against base commit 19c5bf0. This pull request removes 2 and adds 47 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Test Results - Alternative Providers154 tests 30 ✅ 33s ⏱️ Results for commit 8a097e6. ♻️ This comment has been updated with latest results. |
LocalStack Community integration with Pro 2 files ± 0 2 suites ±0 59m 15s ⏱️ - 58m 50s Results for commit 8a097e6. ± Comparison against base commit 19c5bf0. This pull request removes 1978 and adds 25 tests. Note that renamed tests count towards both.This pull request removes 225 skipped tests and adds 13 skipped tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Test Results (amd64) - Integration, Bootstrap 5 files 5 suites 1h 27m 26s ⏱️ Results for commit 8a097e6. ♻️ This comment has been updated with latest results. |
bentsku
left a comment
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.
Nice update! We can enable many more tests, and this looks great!
I've added a few comments that are mostly all related to one change that would be required: removing the topic_subscriptions attribute from the store, and making that part of the topic itself. Once this is addressed and all the related changes are done, I think we're good to merge that one!
There's also the failing test we need to have a look at, not sure what happened, but the snapshot is now broken.
This looks great, it's nice to see so much core logic already ported 🚀
|
|
||
| store = self.get_store(account_id=parsed_topic_arn["account"], region=context.region) | ||
|
|
||
| if topic_arn not in store.topic_subscriptions: |
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: this should now be if topic_arn not in store.topics
We should try to unify usage of topics around the codebase and avoid having multiple attributes for the same resource
could be (for future usage in this same function)
if topic_arn not in store.topics:
raise NotFoundException("Topic does not exist")
topic_subscriptions = store.topics[topic_arn]["subscriptions"]and then topic_subscriptions can be used through this function
| with contextlib.suppress(ValueError): | ||
| store.topic_subscriptions[subscription["TopicArn"]].remove(subscription_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.
here this will be adapted to remove it from the store.topics[subscription["TopicArn"]]["subscriptions"] instead
| # TODO: add topic attributes once they are ported from moto to LocalStack | ||
| # topic_attributes=vars(self._get_topic(topic_arn, context)), |
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 believe those should now be present in the topic, right?
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.
yes, but as I was not yet sure about the PublishContext and the exact effects of the code, I would rather do this together with publish
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.
makes sense 👍 I believe it will be enough to pass the topic["attributes"], let's check it later! 👍
0196e37 to
d37f9d5
Compare
d37f9d5 to
aa2e024
Compare
|
Most important change since the last review @bentsku is that the subscription objects are now directly referenced in the topic (not just their arns where you then have to check the store again. They can still live outside topics because they are stored in "subscriptions" as well, this just saves this one level of lookup) |
bentsku
left a comment
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.
Almost good to go! Sorry for the multiple iterations on this. I think we should keep the topic's subscriptions as only a list of ARN, and store the data in only one store attributes and not have the same data stored in 2 places (see my comment for more context on this).
I can also see all the new tests being added but not validated, is it worth adding them now, or should it be its own PR? As they don't add anything yet as they still need to be validated. I'm also fine leaving them in if it makes your life easier to avoid future conflicts. We probably need to mark them as needs_fixing and not unknown then, unknown was more of a "transitive" marker when we started adding markers to existing tests.
Otherwise, the rest looks good! 👍
| store.subscriptions[subscription_arn] = subscription | ||
|
|
||
| topic_subscriptions.append(subscription) |
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.
this works currently because the references are shared: both store.subscriptions[susbcription_arn] and store.topics[topic_arn][subscription_index] share the same reference to the underlying Subscription object.
but when restoring state, we're going to go from serialized state back to Python object, and the framework will create 2 different objects that time, and set_subscription_attributes is not going to work anymore because you're only going to modify one object that is not shared with the other.
I think it might be easier to keep only the subscription ARN in the topic's subscriptions to avoid the issue. I think it is fine to have both look ups: you check if the subscription is in the topic's subscriptions first, then you fetch the subscription from the store subscriptions.
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.
Thank you for clarifying this, I wondered this exact point but assumed that the reference would be kept. I find it interesting to be honest that this doesn't work (my assumption was that a lot of stuff could easily break if object identity is not respected on restore). Something for a coffee chat at some point :D Will change it back
| resp = aws_client.sns.list_subscriptions_by_topic(TopicArn=topic_arn) | ||
| assert "NextToken" in resp | ||
|
|
||
| @pytest.mark.skip(reason="TODO") |
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.
question: are all those new tests straight ported from Moto, with no AWS validation? is it worth having them in the same PR, or should they be in a different PR and being validated at the same 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.
I would like to leave them in if that's alright with you, I created a linear ticket so this doesn't get lost and marked them all as "needs fixing"
This reverts commit a1a499a.
bentsku
left a comment
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! Thanks for addressing all the comments, this looks perfect now 👌
| # subscribe calls do nothing (subscribe is idempotent), except if its attributes are different. | ||
| for existing_topic_subscription in topic_subscriptions: | ||
| if existing_topic_subscription.get("Endpoint") == endpoint: | ||
| sub = store.subscriptions.get(existing_topic_subscription, {}) |
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.
praise: very nice change!
Motivation
This PR applies the changes of #13095 on top of #13205. It also adds subscription attribute functions, as well as confirm_subscription.
closes PNX-78, closes PNX-76, closes PNX-95
Changes
What's left to do: