Repository navigation
feat(cfn): DescribeStackEvents answers, derived from the stack record (#501) - #597
Merged
Merged
Conversation
…#501) The operation returned UnsupportedOperation (400), so a consumer's deployment wrapper — which polls events, because that is where a CloudFormation failure is conventionally read from — could not run against substrate at all. Events are derived from the stack record rather than the event log, which is a departure from the route #501 filed as preferred. Two measurements ruled the log out: a recorded Event carries no LogicalResourceId (RecordRequest never copies reqCtx.Metadata onto it) and every StackEvent needs one; and the store is disabled for in-process emulator.Client callers, who would have seen an empty list for a stack that plainly deployed. Resource events are terminal only and a deploy's events share one instant. Substrate deploys synchronously, so it never observed a resource mid-create; spacing the events apart is unavailable because simulated time advances with wall time, which would make a consumer's assertions wall-clock dependent — the finding sqs_control.go already records. Order is carried by position instead. Closes #501's fifth-criterion blocker on #562: a stack whose service role is missing one permission now reports a StackEvent naming the AccessDeniedException and the action refused. DescribeStackResources shares the same derivation (cfnResourceStatus), so the two views cannot disagree.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DescribeStackEventsreturnedUnsupportedOperation(400), so a consumer's deploymentwrapper — which polls events, because that is where a CloudFormation failure is
conventionally read from — could not run against substrate at all. That refusal also
blocked #562's fifth acceptance criterion, which deferred that issue across four
releases.
Closes #501
Closes #562
The events are derived from the stack record, not the event log
This is a departure from the route #501 filed as its preferred one, and two
measurements are why.
A recorded
Eventcannot name a resource.EventStore.RecordRequest(
emulator/eventstore.go:310-319) builds an event from the request context and theoperation and never copies
reqCtx.Metadataonto it, so the log knowss3:CreateBucket at Tbut not which logical resource that was — and every usefulStackEventcarries aLogicalResourceId. Deriving from the log would mean guessingwhich recorded call belonged to which resource, which invents more than reading the
record does.
The event store is disabled for in-process callers. The CFN plugin substitutes a
disabled store when none is passed (
cloudformation_plugin.go:114-117), so anemulator.Clienttest would have seen an empty list for a stack that plainly deployed.TestCFNEvents_DerivesWithoutAnEventStoreis the regression guard.cfnResourceStatusis factored out ofdescribeStackResourcesand shared, so the twoviews cannot disagree about whether a resource failed.
Terminal states only, and one instant per deploy
Substrate deploys synchronously, so it never observed a resource mid-create and holds no
record that one existed — a per-resource
CREATE_IN_PROGRESSwould be fabricated. Thestack's own bracketing events are different: the record's status names the operation
that ran and its timestamps say when.
Spacing the events apart was considered and rejected for a reason already recorded in
emulator/sqs_control.go:20-27:TimeController.Now()advances with wall time, so anyinterval substrate manufactured would make a consumer's assertions wall-clock dependent.
Order is carried by position instead — reverse deployment order within an instant, which
is what real CloudFormation shows. This also settles the clock question #501 and #514
were both waiting on; #514 is not a blocker and stays open on its own EC2 merits.
EventIdis deterministic:{LogicalId}-{ResourceStatus}-{Timestamp}for a resource,which is the form AWS's own sample response returns, and a UUID derived from the stack
ARN, status and timestamp for a stack event. A replayed stack reports byte-identical
events.
Verification
gofmt,go build,go vet,golangci-lint run ./...→ 0 issues,make test(race),
make coverage(81.5% emulator / 80.8% total),make docs-reference docs-reference-check docs-versions, the docs site build, andtest/e2eall green.Verified live through the AWS CLI, including #562's criterion:
An unknown stack, and a stack deleted successfully, both report
ValidationError—matching
DescribeStacks, and #501 point 6's honest answer.Mutation testing: 12 mutants, 11 caught. The survivor was a real defect rather than a
test gap: a
sort.SliceStableby timestamp that could never reorder anything, becausethe list is already non-decreasing in time when built. It was removed rather than covered
by a test for an unreachable branch. Mutants included ordering reversed, the
reverse-deployment tiebreak dropped,
ResourceStatusReasondropped for a failedresource, the sweep's deletion overlay skipped, both
EventIdforms madenon-deterministic,
NextTokenemitted on a complete page, the cursor ignored, theopening event fabricated for a status-less record, an update reporting a create's
opening event, the derivation gated on the event store, the shared derivation split, and
a per-resource
CREATE_IN_PROGRESSfabricated.Compatibility
DescribeStackEventspreviously returnedUnsupportedOperation(400) and now returns200. A test asserting the refusal will fail —
TestCFNPlugin_DescribeStackEventswas such a test and is replaced knowingly, which iswhat #501's own acceptance criteria asked for.
The
docs/services.md"DescribeStackEvents is not supported" section is deleted andreplaced with what the model does and does not contain, and the paragraph claiming a
role denial is "not reported as a
StackEvent" is now false and rewritten.