Skip to content

Conversation

pinzon
Copy link
Member

@pinzon pinzon commented Sep 9, 2024

Motivation

Addresses #10826. The resource_provider class only stores the new model properties if the create operation is successful. This can cause issues where a nested stack reaches a failed status after being in a pending state. The Id property is never stored, and if the delete method is called, the property required for deletion cannot be found.

Changes

  • Now the resource_provider stores the model properties

Testing

  • New aws validated test based on issue triaged.

@pinzon pinzon force-pushed the fix-nested-stack-deletion branch from 77226ec to 0872119 Compare September 9, 2024 20:57
Copy link

github-actions bot commented Sep 9, 2024

LocalStack Community integration with Pro

    2 files  ±0      2 suites  ±0   1h 37m 0s ⏱️ -53s
3 439 tests +1  3 041 ✅ +2  398 💤  - 1  0 ❌ ±0 
3 441 runs  +1  3 041 ✅ +2  400 💤  - 1  0 ❌ ±0 

Results for commit 229c705. ± Comparison against base commit df051a8.

♻️ This comment has been updated with latest results.

@pinzon pinzon changed the title fix deletion of failed nested stack fix deletion of failed nested stack in CFn Sep 11, 2024
@pinzon pinzon added the semver: patch Non-breaking changes which can be included in patch releases label Sep 11, 2024
@pinzon pinzon marked this pull request as ready for review September 11, 2024 18:32
Copy link
Contributor

@simonrw simonrw left a comment

Choose a reason for hiding this comment

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

Nice consistency change, thanks for resolving! A couple of minor suggestions, but LGTM!

@@ -81,7 +82,7 @@ def test_nested_stack_output_refs(deploy_cfn_template, s3_create_bucket, aws_cli
assert f"{nested_bucket_name}-suffix" == result.outputs["CustomOutput"]


@pytest.mark.skip(reason="Nested stacks don't work properly")
@pytest.mark.skip(reason="Nested rtacks don't work properly")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
@pytest.mark.skip(reason="Nested rtacks don't work properly")
@pytest.mark.skip(reason="Nested stacks don't work properly")

Copy link
Member Author

Choose a reason for hiding this comment

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

An error from my part but thanks to it I found that we can delete the skip

Comment on lines 345 to 350
def _stack_and_child_deleted():
stacks = aws_client.cloudformation.describe_stacks()["Stacks"]
stacks_with_name = [s for s in stacks if stack_name in s["StackName"]]
assert len(stacks_with_name) == 0

retry(_stack_and_child_deleted, sleep=2 if is_aws_cloud() else 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you use a waiter here? Also it might be clearer to describe_stack(StackName=stack_name) and catch the exception?

Copy link
Member Author

Choose a reason for hiding this comment

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

Took a while but test is a lot better now. I'll merge once is green.

@pinzon pinzon force-pushed the fix-nested-stack-deletion branch from a54f267 to 229c705 Compare September 17, 2024 20:44
@pinzon pinzon merged commit 7f616af into master Sep 19, 2024
34 checks passed
@pinzon pinzon deleted the fix-nested-stack-deletion branch September 19, 2024 00:33
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.

2 participants