Repository navigation
fix(allocation): destroy and apply free the ledger entries of machines gone; teardown forgets stale ones - #120
Merged
Merged
Conversation
…s gone; teardown forgets stale ones apply frees the entries of machines that left the Terraform state and urbex.yaml no longer declares; destroy frees every machine the state held, not only the declared ones. teardown, with no environment left, forgets entries whose machines are gone from Proxmox and stops, naming them, on those that still exist. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0182yxsfwRowwnxCfgrQwjnA
stefanoghinelli
approved these changes
Nov 18, 2026
2 tasks done
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.
Summary
internal/provision/ledger.go(new):stateHostnames: the machines in an environment's Terraform state (module.service["…"],module.vm["…"]), declared inurbex.yamlor not;freeGone: removes from the allocation ledger the machines that left the state and thaturbex.yamlno longer declares, and says so (Freed the addresses of …).apply: reads the state before (vanished machines included) and afterterraform apply, and frees the addresses of what left. That covers an application removed fromurbex.yamland deleted byapply --delete-data(or a plain delete), which is howpgtest-board-stagingstayed in the lab's ledger.destroy: frees every machine its state held, not only the servicesurbex.yamllists.teardown: with no environment folder left, an entry the ledger still holds (left by an older urbex) is forgotten if its machine is gone from Proxmox (Forgot stale entries of the allocation ledger …, naming host and VMID). If its machine still exists, teardown stops and names it, with what to do: delete it in the pool, or put its application back andurbex destroy. Nothing urbex doesn't account for is deleted. Before, any ledger entry was a bare "project environments still exist".TestStateHostnames,TestFreeGone(removed and deleted → freed; still declared → kept; another project's → kept),TestForgetStaleLedger(all gone → forgotten; one live → stops naming it).Companion docs: urbforge/urbex#93.
Why
#115, found in the Forgejo spike: a stale
pgtest-board-stagingentry (the application had been removed fromurbex.yamlbefore its environment was destroyed) blockedurbex teardown, and had to be removed by hand.Tests I ran
go test ./...,mise run lint: pass.mise run e2e: PASSED (24 steps), destroy and teardown included.Checklist before review
Fixes #115
🤖 Generated with Claude Code
https://claude.ai/code/session_0182yxsfwRowwnxCfgrQwjnA