mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
* feat(cloudformation): list a deleted stack and report its DeletionTime A deleted stack is already retained so DescribeStacks and DescribeStackEvents keep answering for it by stack id after the delete, but the record they answer with was incomplete in two ways. It carried no deletion time, so DescribeStacks reported DELETE_COMPLETE with nothing saying when. Stack now has a deletionTime, set as the stack reaches DELETE_COMPLETE from the same service clock the retention window uses, and the query handler emits DeletionTime wherever AWS does. ListStacks omitted deleted stacks entirely. AWS keeps one there as DELETE_COMPLETE long after DescribeStacks has stopped answering for it by name, which is how a client reconciles what it deployed against what is left, and a StackStatusFilter of DELETE_COMPLETE selects exactly those. Retained stacks are now merged into the listing, still scoped to the caller's account and region and still dropped once the window passes. A name reused after a delete lists twice, once per stack id, as it does on AWS. Resource Explorer reads the live map directly and is unaffected. Restores deleted-stack-retention-seconds to application.yml, which #849 dropped in a merge: the knob kept working on its @WithDefault, but the repository YAML is the source of truth for what a deployment actually runs. Pinned in the test YAML too, since the retention tests advance the clock past that exact window. Nothing here changes how a delete runs, and it does not make a multi-stack cdk destroy work: that client polls a destroy entirely by stack name, so a record retained by stack id, these two members included, never enters its path. DeleteStack does already return before the delete finishes, and the stack does pass through DELETE_IN_PROGRESS, but the whole delete completes in roughly 15ms, well inside one poll interval, so a client that starts watching when it issues the delete finds the stack gone by name on its first poll. Giving a deleting stack an observable window is separate work. * fix(cloudformation): set a stack's deletion time before publishing the status Stack.status is volatile and is documented as the publishing write of a deploy: a reader that observes a terminal status is guaranteed to observe every write that preceded it. deletionTime was assigned after it, outside that guarantee, so a DescribeStacks running concurrently with the last step of a delete could observe DELETE_COMPLETE while deletionTime was still null and answer with no DeletionTime element at all. Assigning it first puts it inside the same happens-before edge as the rest of the delete. The window is nanoseconds wide and no test can land in it reliably, so this carries none; the ordering rule is the thing being fixed, and the comment records it so the next edit here keeps it. * fix(cloudformation): retain a deleted stack before it leaves the live map The handover at the end of a delete removed the stack from the live map, wrote its removal through to storage, and only then retained it as deleted. A ListStacks landing between the removal and the retention found it in neither map and dropped it from the listing, though the stack both existed a moment ago and is retained a moment later. Retaining before removing closes that window. The stack is then briefly in both maps, which is harmless: they hold the same Stack, and listStacks now reduces by stack id, so it is listed exactly once throughout. Nothing else reads both maps, since resolveStackForDescribe consults the retained one only after the live lookup has missed. Greptile reported the listing could also show the stack twice. It could not: the old order removed before it inserted, so the two maps never overlapped. The duplicate only becomes possible with this ordering, which is why the reduction comes with it. The test drives 60 deletes with four concurrent listings each. It fails on every run against the old ordering and passes on every run against this one. It pins the retention window open through a profile: the window is measured on the test MutableClock, which advances on every read, and the pollers would otherwise expire the retained record themselves. * style(cloudformation): order the Stream import with the rest of java.util java.util.stream.Stream landed between java.util.regex and java.util.concurrent when it was added. It now follows both, the order AGENTS.md asks for. Only the line this branch introduced moves; the block's older irregularities are left where they are. * fix(cloudformation): read the live stacks before creating the deleted-stack view Retaining a stack before removing it keeps it in at least one map at every instant, but listStacks built both of its views up front, the retained one first and the live one after. A ConcurrentHashMap view reflects the table at some point at or since its own creation and is not guaranteed to reflect a modification made after it, so the retained view, created before the retain, need never show the stack, while the live view, created after the remove, can already miss it. A listing landing there loses the stack in both, which is the window the retain-before-remove ordering was meant to close. Traversing the retained view second does not help: creation bounds the guarantee, not traversal. The maps are now read one after the other instead of through a concatenated pipeline, the live one first and in full, so the retained view is created after any remove the live pass could have missed, and therefore after the retain that preceded it. The reduction by stack id stays: the overlap it covers is real. No test. The fault is the absence of a JDK guarantee rather than a behaviour: these views do in practice reflect a later put, so the old ordering passes every time and nothing can force it not to. The existing listing-race test still covers the retain-before-remove ordering this rests on. The java.util.stream.Stream import goes with Stream.concat, which the change removes. * test(cloudformation): stop the listing-race pollers on every exit path The pollers were stopped after awaitDeleted returned, so a throw from the delete or the wait left four non-daemon threads spinning on listStacks for the rest of the run. That holds the test JVM open and buries the failure that caused it under a hang, which is a far worse thing to debug than the failure itself. Shutdown moves into a finally, so a failing delete stops them on its way out. Each join is bounded and a thread still alive afterwards is interrupted and recorded, with the poller loop now checking its own interrupt flag so that interrupt is not merely decorative. The check that they all stopped is asserted after the try and never inside the finally, where it would replace whatever the delete threw with its own failure. The threads are daemons as a backstop, so a future edit that throws somewhere nothing throws today still cannot wedge the suite. Also replaces an assertTrue(false, ...) in the wait helper with fail(...), which says the same thing and reads as what it is. Noted here rather than slipped in.