{"id":"XE-13369","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"512","source_url":"https://github.com/xeprotocol/xe/issues/512","reporter_id":1981,"title":"Laporan bug","area":"leasing-ledger","claimed_tier":null,"assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"closed","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-14T20:42:12.267913+00:00","updated_at":"2026-11-20T00:38:14.109859+00:00","source_created_at":"2026-11-12T16:22:27+00:00","told_at":"2026-11-20T00:34:45+00:00","status_changed_at":"2026-11-20T00:33:18.442331+00:00","url":"https://bounty.xe.network/XE-13369","body":"# XE Bounty — Laporan siap file (temuan pass 5 #5)\n\nFile issue baru di: https://github.com/xeprotocol/xe/issues/new\nPaste judul + isi di bawah. Akun GitHub: Gib230223.\n\n---\n\n## Judul\n\n[Low] Lima Provision: `limactl create` failure leaks the instance — no `delete --force`, unlike the start/SSH failure paths\n\n## Isi\n\n## Summary\n\n`LimaManager.Provision` has three failure paths after the template is written. The `start` and `waitForSSHPort` paths both clean up (stop + `delete --force` + remove template). The `create` path removes only the template file — it never deletes the instance. A `create` that fails after the instance exists leaves disk/state behind, blocks re-provision of the same lease name (`limactl create` with the same name fails while the orphan exists), and is only reaped by `cleanOrphans` at next manager construction (node restart).\n\n## Evidence\n\n```go\n// vm/lima_manager.go:120-123 — create failure: template removed, instance NOT deleted:\nif _, err := m.runLimactlWithTimeout(2*time.Minute, \"create\", \"--tty=false\", \"--name=\"+name, templatePath); err != nil {\n    _ = os.Remove(templatePath)\n    return nil, fmt.Errorf(\"lima create: %w\", err)\n}\n\n// vm/lima_manager.go:125-133 — start failure: delete --force + template removed:\nif _, err := m.runLimactlWithTimeout(5*time.Minute, \"start\", \"--tty=false\", name); err != nil {\n    diag := m.captureDiagnosticLogs(name)\n    _, _ = m.runLimactl(\"delete\", \"--force\", name)\n    _ = os.Remove(templatePath)\n    ...\n}\n\n// vm/lima_manager.go:135-144 — waitForSSHPort failure: stop + delete --force + template removed:\nif _, err := m.waitForSSHPort(name, 2*time.Minute); err != nil {\n    diag := m.captureDiagnosticLogs(name)\n    _, _ = m.runLimactl(\"stop\", name)\n    _, _ = m.runLimactl(\"delete\", \"--force\", name)\n    _ = os.Remove(templatePath)\n    ...\n}\n```\n\nThe only other cleanup is `cleanOrphans` (`vm/lima_manager.go:325`), which deletes every `xe-*` limactl instance — but it runs only in the constructor (`NewLimaManager`, line ~85), i.e. at node restart. Within a running process, a failed create leaves a live orphan that also blocks a retry of the same lease: `Provision` checks only its in-memory `m.vms` map (which has no entry for the failed lease), so the retry reaches `limactl create --name=xe-<hash>` again and fails on the existing instance name.\n\n## Impact (Low)\n\nOrphaned Lima instances accumulate on disk after create failures, and the affected lease cannot be re-provisioned until the node restarts (when `cleanOrphans` runs). Severity is Low: narrow trigger (create must fail after the instance exists — e.g. disk provisioning failure), bounded impact (one instance per failed lease, reaped at restart), no fund movement.\n\n## Reproduction (PoC)\n\nTest with a fake `limactl` script, `vm/poc5_lima_create_leak_test.go`, `TestPoc5LimaCreateLeak`, `go test ./vm/ -run TestPoc5LimaCreateLeak -v -count=5`. The fake records every invocation; `create` touches a marker file (simulating the instance on disk) and then fails; `delete --force` removes the marker. Phase 1 stages a create failure and asserts zero `delete --force` calls with the marker still present; phase 2 (control) stages a start failure and asserts `delete --force` IS called.\n\nCoordinator run (2026-11-12 ~23:18 WIB), 5/5 PASS:\n\n```\nphase 1: create failed as staged; delete --force calls so far: 0 (want 0); instance marker present: yes\nphase 2: start failed as staged; delete --force calls total: 1\nBUG REPRODUCED: `limactl create` failure leaves the instance behind (0 delete --force calls), while the `start` failure path cleans up (1 call) — Provision's create error path removes only the template file\n```\n\n## Suggested fix\n\nMirror the start-failure path in the create-failure path:\n\n```go\nif _, err := m.runLimactlWithTimeout(2*time.Minute, \"create\", \"--tty=false\", \"--name=\"+name, templatePath); err != nil {\n    _, _ = m.runLimactl(\"delete\", \"--force\", name)\n    _ = os.Remove(templatePath)\n    return nil, fmt.Errorf(\"lima create: %w\", err)\n}\n```\n\n## Novelty note\n\nNo ticket covers Lima create-failure cleanup. Closest, all verified: XE-1438 (QEMU/Lima VM managers bind guest SSH on 0.0.0.0, premature SLIRP readiness, GPU FLR, global lock — different defects in the same managers); pass-3 #5 (QEMU *workdir* leak on `waitForQEMUPID`/`waitForSSHPort` failure — different manager, different leaked resource, different failure paths). Board greps for lima/limactl/create-leak/orphan return no ticket; GitHub live `search_issues` returns 0 hits. Checked the live bounty board (High+Medium and Minor views) and the GitHub repo issues, 2026-11-12.\n\nRepo: github.com/xeprotocol/xe, HEAD 89a542e, testnet-0005.\n","patch_refs":[{"id":562,"repo":"xeprotocol/xe","kind":"pr","ref":"516","title":"fix(vm): cleanup orphaned instance with delete --force on lima create failure (fixes #512)","url":"https://github.com/xeprotocol/xe/pull/516","note":"","state":"open","author":"arturbarszcz78","added_by":"desk","created_at":"2026-11-14T20:42:20.148168+00:00"}],"thread":[{"id":13212,"source":"github","source_ref":"7026485037","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, file a new report that links https://bounty.xe.network/XE-13369 and says what differs; it is read like any other.","created_at":"2026-11-20T00:34:45+00:00"}]}