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 SQS CFn updates with no change #9831

Merged
merged 3 commits into from Dec 12, 2023
Merged

Fix SQS CFn updates with no change #9831

merged 3 commits into from Dec 12, 2023

Conversation

simonrw
Copy link
Contributor

@simonrw simonrw commented Dec 8, 2023

Motivation

If a CFn stack containing an SQS queue is updated, but the SQS queue is not changed, we trigger invalid behaviour where we assume information in the incoming request that is not present. Specifically, we try to get the queue name from the incoming state, and if this was not specified in the first place (i.e. we rely on auto-generating the queue name) the stack fails to update.

While investigating this issue I found another issue when adding a completely new resource. The "update" method is still invoked, but because we raise a NotImplementedError we try to handle this in the executor, but this assumes there is a previous state. For a completely new resource, this is not the case.

Closes #9826

Changes

  • Add test for updating SQS queues
  • Fix updating sqs queues
  • Fix situations where an update is incorrectly detected for a completely new resource

@simonrw simonrw added the semver: patch Non-breaking changes which can be included in patch releases label Dec 8, 2023
@simonrw simonrw self-assigned this Dec 8, 2023
Copy link

github-actions bot commented Dec 8, 2023

LocalStack Community integration with Pro

       2 files  ±0         2 suites  ±0   1h 12m 27s ⏱️ - 1m 11s
2 401 tests +2  2 173 ✔️ +2  228 💤 ±0  0 ±0 
2 402 runs  +2  2 173 ✔️ +2  229 💤 ±0  0 ±0 

Results for commit e04ad50. ± Comparison against base commit e9f45c4.

♻️ This comment has been updated with latest results.

@simonrw simonrw force-pushed the fix/cfn/sqs-update branch 2 times, most recently from f6d395f to 5dfb519 Compare December 11, 2023 09:18
Comment on lines 189 to 195
should_replace = (
request.desired_state.get("QueueName", request.previous_state["QueueName"])
!= request.previous_state["QueueName"]
) or (
request.desired_state.get("FifoQueue", request.previous_state["FifoQueue"])
!= request.previous_state["FifoQueue"]
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dominikschubert there must be a way to automate this sort of detection from the spec... 🤔

@coveralls
Copy link

Coverage Status

coverage: 84.029% (+0.008%) from 84.021%
when pulling e04ad50 on fix/cfn/sqs-update
into e9f45c4 on master.

@simonrw simonrw marked this pull request as ready for review December 11, 2023 18:10
@simonrw simonrw requested review from bentsku and removed request for pinzon and baermat December 11, 2023 18:10
Comment on lines +813 to +814
# this is an issue with our update detection. We should never be in this state.
request.action = "Add"
Copy link
Member

Choose a reason for hiding this comment

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

so is this a TODO for the framework? or what do we do about the comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an issue with the CFn engine in LocalStack. We should never try to perform an update/modify on a resource that has no previous state, since this means the resource has not been created yet.

Copy link
Member

Choose a reason for hiding this comment

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

I think it's fine as a fix for now until the update detection is fixed

Copy link
Member

@thrau thrau left a comment

Choose a reason for hiding this comment

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

LGTM! thanks for adding the test

Copy link
Contributor

@bentsku bentsku left a comment

Choose a reason for hiding this comment

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

LGTM! thanks for making this cover more use cases and upgrading my very naive fix!

@simonrw simonrw merged commit 7488c72 into master Dec 12, 2023
26 checks passed
@simonrw simonrw deleted the fix/cfn/sqs-update branch December 12, 2023 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: SQS queues cause deployment failures when using IaC (AWS CDK)
5 participants