Skip to content
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

fix(sns): race condition exists between sqs queue policy and sns subscription #21259

Closed
wants to merge 3 commits into from

Conversation

jonnekaunisto
Copy link
Contributor

@jonnekaunisto jonnekaunisto commented Jul 20, 2022


Fixes #20665 by adding a dependency to sqs policy for sns subscriptions.

All Submissions:

Adding new Unconventional Dependencies:

  • This PR adds new unconventional dependencies following the process described here

New Features

  • Have you added the new feature to an integration test?
    • Did you use yarn integ to deploy the infrastructure and generate the snapshot (i.e. yarn integ without --dry-run)?

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

@gitpod-io
Copy link

gitpod-io bot commented Jul 20, 2022

@github-actions github-actions bot added the p2 label Jul 20, 2022
@aws-cdk-automation aws-cdk-automation requested a review from a team July 20, 2022 22:56
@github-actions github-actions bot added bug This issue is a bug. effort/small Small work item – less than a day of effort p1 and removed p2 labels Jul 20, 2022
@TheRealAmazonKendra TheRealAmazonKendra changed the title fix(sns): add dependency to sqs policy for sns subscription fix(sns): race condition exists between sqs queue policy and sns subscription Jul 21, 2022
Copy link
Contributor

@TheRealAmazonKendra TheRealAmazonKendra 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 for your contribution! Looks like edits to the integration tests were missed so the build is failing. We'll also nee unit tests for this change. Just a few comments below about the actual change.


// Add the subscription policy as a dependency for the subscription
const subscriptionDependencies: IDependable[] = [];
if (queuePolicyDependable) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You're setting this a few lines above. Under what conditions would this not be defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not defined if the queue is imported or if autoCreatePolicy is set to false while no queue policy exists: https://github.com/aws/aws-cdk/blob/v1.159.0/packages/%40aws-cdk/aws-sqs/lib/queue-base.ts#L144

*
* @default - empty list
*/
readonly subscriptionDependencies?: IDependable[];
Copy link
Contributor

Choose a reason for hiding this comment

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

You're only adding one dependable here so why make it an array? Also, your logic above doesn't seem to have a scenario where subscriptionDependencies is undefined so I'm not sure why this would be optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made it an array to make it generic, but I guess it's not backwards incompatible to change this in the future to a list if needed.

It needs to be undefined because only the SQS subscription needs to set this, the lambda and email subscription don't need this: https://github.com/aws/aws-cdk/blob/v1.159.0/packages/%40aws-cdk/aws-sns-subscriptions/lib/email.ts, https://github.com/aws/aws-cdk/blob/v1.159.0/packages/%40aws-cdk/aws-sns-subscriptions/lib/sms.ts, https://github.com/aws/aws-cdk/blob/v1.159.0/packages/%40aws-cdk/aws-sns-subscriptions/lib/lambda.ts

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really see any value to make it an array when we only expect one value here. It's adding unnecessary logic elsewhere.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 87a1b3d
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

*
* @default - empty list
*/
readonly subscriptionDependencies?: IDependable[];
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really see any value to make it an array when we only expect one value here. It's adding unnecessary logic elsewhere.

@aws-cdk-automation
Copy link
Collaborator

This PR has been in the BUILD FAILING state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week.

@aws-cdk-automation
Copy link
Collaborator

This PR has been deemed to be abandoned, and will be automatically closed. Please create a new PR for these changes if you think this decision has been made in error.

@aws-cdk-automation aws-cdk-automation added the closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. label Aug 19, 2022
mergify bot pushed a commit that referenced this pull request Oct 2, 2022
…cription (#21797)

----

Fixes #20665 by adding a dependency to sqs policy for sns subscriptions.
### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

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


This is a follow up to #21259, which got closed for failing for too long
arewa pushed a commit to arewa/aws-cdk that referenced this pull request Oct 8, 2022
…cription (aws#21797)

----

Fixes aws#20665 by adding a dependency to sqs policy for sns subscriptions.
### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

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


This is a follow up to aws#21259, which got closed for failing for too long
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/small Small work item – less than a day of effort p1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Race condition between SQS QueuePolicy and SNS Subscription
3 participants