mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
Add a deterministic regression test: a nested stack resource that fails to create must roll the parent back rather than report CREATE_COMPLETE with its Fn::GetAtt output left as the raw literal. It fails on the pre-#3609 matching logic and passes on main. #3609 fixed #3854. The volatile on Stack.status stays as a documented invariant (the deploy thread writes status last); it is not the fix. Refs #3854 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>
This commit is contained in:
1 parent
a6d330384e
commit
ee4acfdf81
2 files changed
+102
-3
No files matched your search
+93
-2
@@ -200,7 +200,7 @@ class CloudFormationIntegrationTest {
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("cf-test-queue"));
|
||||
|
||||
|
||||
// 4. Describe Stacks
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
@@ -6708,6 +6708,97 @@ class CloudFormationIntegrationTest {
|
||||
.body(containsString("nested-stack-child-queue"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Pins the actual root cause behind issue #3854 (a parent stack output resolving to the raw
|
||||
* {@code LogicalId.Outputs.Key} literal instead of a nested stack's value), which turned out
|
||||
* to have nothing to do with cross-thread visibility.
|
||||
*
|
||||
* <p>{@code executeNestedStack} copies {@code childStack.getOutputs()} into the parent
|
||||
* resource's {@code Outputs.*} attributes right after the child's (synchronous, same-thread)
|
||||
* {@code executeTemplate} call returns. When the child's own resource loop fails, {@code
|
||||
* executeTemplate} never reaches its Outputs block at all: {@code rollbackFailedExecution}
|
||||
* rewrites the child's status straight from {@code CREATE_FAILED} into {@code
|
||||
* ROLLBACK_COMPLETE} before returning. {@code executeNestedStack} used to detect a failed
|
||||
* child only by checking for the literal strings {@code CREATE_FAILED}/{@code UPDATE_FAILED},
|
||||
* which a rolled-back create can never match, so the parent kept going and reported
|
||||
* {@code CREATE_COMPLETE} with its {@code Fn::GetAtt} on the child's outputs left unresolved:
|
||||
* exactly the symptom in #3854. That matching bug was already fixed by allow-listing the
|
||||
* success statuses instead (commit 700d403, PR #3609) before #3854 was even filed; this test
|
||||
* only adds the missing regression coverage tying it to this issue.
|
||||
*/
|
||||
@Test
|
||||
void createStack_failingNestedStackResource_rollsBackParentInsteadOfReportingUnresolvedOutput() {
|
||||
String childTemplate = """
|
||||
{
|
||||
"Resources": {
|
||||
"ConflictingSecret": {
|
||||
"Type": "AWS::SecretsManager::Secret",
|
||||
"Properties": {
|
||||
"Name": "cfn-3854-nested-conflict-secret",
|
||||
"SecretString": "explicit",
|
||||
"GenerateSecretString": { "PasswordLength": 32 }
|
||||
}
|
||||
}
|
||||
},
|
||||
"Outputs": {
|
||||
"SecretArn": { "Value": { "Ref": "ConflictingSecret" } }
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
given().when().put("/issue-3854-templates").then();
|
||||
given().contentType("application/json").body(childTemplate)
|
||||
.when().put("/issue-3854-templates/failing-child.json")
|
||||
.then().statusCode(200);
|
||||
|
||||
String parentTemplate = """
|
||||
{
|
||||
"Resources": {
|
||||
"FailingNestedStack": {
|
||||
"Type": "AWS::CloudFormation::Stack",
|
||||
"Properties": {
|
||||
"TemplateURL": "http://localhost/issue-3854-templates/failing-child.json"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Outputs": {
|
||||
"childSecretArn": {
|
||||
"Value": { "Fn::GetAtt": ["FailingNestedStack", "Outputs.SecretArn"] }
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
String stackName = "issue-3854-failing-nested-parent";
|
||||
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "CreateStack")
|
||||
.formParam("StackName", stackName)
|
||||
.formParam("TemplateBody", parentTemplate)
|
||||
.when().post("/").then().statusCode(200);
|
||||
|
||||
String xml = null;
|
||||
long deadline = System.currentTimeMillis() + 20_000;
|
||||
while (System.currentTimeMillis() < deadline) {
|
||||
xml = given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "DescribeStacks")
|
||||
.formParam("StackName", stackName)
|
||||
.when().post("/")
|
||||
.then().statusCode(200)
|
||||
.extract().asString();
|
||||
if (xml.contains("<StackStatus>ROLLBACK_COMPLETE</StackStatus>")
|
||||
|| xml.contains("<StackStatus>CREATE_COMPLETE</StackStatus>")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
assertThat(xml, containsString("<StackStatus>ROLLBACK_COMPLETE</StackStatus>"));
|
||||
assertThat(xml, not(containsString("<StackStatus>CREATE_COMPLETE</StackStatus>")));
|
||||
assertThat(xml, not(containsString("FailingNestedStack.Outputs")));
|
||||
}
|
||||
|
||||
// ── Issue #1072: AWS::ApiGatewayV2::Api WEBSOCKET drops RouteSelectionExpression ───
|
||||
|
||||
@Test
|
||||
@@ -7100,7 +7191,7 @@ class CloudFormationIntegrationTest {
|
||||
.body("services[0].taskDefinition",
|
||||
equalTo("arn:aws:ecs:us-east-1:000000000000:task-definition/cfn-ecs-update-taskdef:2"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void deleteStack_ec2SecurityGroup_leavesNoOrphans() {
|
||||
String stackName = "sg-delete-cleanup-stack";
|
||||
|
||||
Reference in new issue
Block a user