mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(cloudformation): give a created stack its template as soon as CreateStack answers (#9008)
A created stack got its template only once its creation started on an operation thread, after CreateStack had answered, so a GetTemplate or GetTemplateSummary in between answered {} and an empty summary. The execution claim, which marks the stack CREATE_IN_PROGRESS under the stack's lock, now sets the template the stack is created with, as it already sets the stack policy, and a claim the operation queue refuses restores the previous template from StackMutationSnapshot with the rest of the stack.
This commit is contained in:
1 parent
ae6d138734
commit
07f93dc8e5
2 files changed
+92
-2
No files matched your search
@@ -1847,7 +1847,7 @@ public class CloudFormationService implements ResourceProvider {
|
||||
List<StackEvent> events,
|
||||
Map<String, ChangeSet> changeSets,
|
||||
Map<ChangeSet, ChangeSetState> changeSetStates,
|
||||
String stackPolicyBody) {}
|
||||
String stackPolicyBody, String originalTemplateBody) {}
|
||||
|
||||
// compute() holds the stack's per-key lock for the whole claim, so only one racing execution can win.
|
||||
private Future<?> claimAndSubmitExecution(String stackNameOrArn, String changeSetName, String region,
|
||||
@@ -1898,6 +1898,11 @@ public class CloudFormationService implements ResourceProvider {
|
||||
if (isCreate && cs.getStackPolicyBody() != null) {
|
||||
existing.setStackPolicyBody(cs.getStackPolicyBody());
|
||||
}
|
||||
if (isCreate) {
|
||||
// The stack has its template once CreateStack answers, as GetTemplate and GetTemplateSummary read
|
||||
// it on AWS, not only once its creation starts, which waits for a free operation thread.
|
||||
existing.setOriginalTemplateBody(cs.getTemplateBody());
|
||||
}
|
||||
existing.setClientRequestToken(clientRequestToken);
|
||||
existing.setStatus(isCreate ? "CREATE_IN_PROGRESS" : "UPDATE_IN_PROGRESS");
|
||||
existing.setLastUpdatedTime(now());
|
||||
@@ -2260,7 +2265,8 @@ public class CloudFormationService implements ResourceProvider {
|
||||
states.put(changeSet, new ChangeSetState(changeSet.getStatus(), changeSet.getExecutionStatus()));
|
||||
}
|
||||
return new StackMutationSnapshot(stack.getStatus(), stack.getLastUpdatedTime(),
|
||||
stack.eventsSnapshot(), stack.changeSetsSnapshot(), states, stack.getStackPolicyBody());
|
||||
stack.eventsSnapshot(), stack.changeSetsSnapshot(), states, stack.getStackPolicyBody(),
|
||||
stack.getOriginalTemplateBody());
|
||||
}
|
||||
|
||||
private void restore(Stack stack, StackMutationSnapshot snapshot) {
|
||||
@@ -2270,6 +2276,7 @@ public class CloudFormationService implements ResourceProvider {
|
||||
stack.setStatus(snapshot.status());
|
||||
stack.setLastUpdatedTime(snapshot.lastUpdatedTime());
|
||||
stack.setStackPolicyBody(snapshot.stackPolicyBody());
|
||||
stack.setOriginalTemplateBody(snapshot.originalTemplateBody());
|
||||
stack.setEvents(new ArrayList<>(snapshot.events()));
|
||||
stack.setChangeSets(new LinkedHashMap<>(snapshot.changeSets()));
|
||||
snapshot.changeSetStates().forEach((changeSet, state) -> {
|
||||
|
||||
Reference in new issue
Block a user