Repository navigation
Description
Summary
A candy-scoped reverse-op is recorded once per candy, but a substrate whose
reverse-op is per-deploy-instance (each deploy:kindcluster records
kind delete cluster --name <that deploy's cluster>) overwrites the previous
deploy's op on the shared candy record. On teardown, when the refcount empties,
only the last recorded op replays — so one cluster leaks per extra deploy
of that candy.
This is the root cause of residue found while proving charly#680 with a
kindcluster bed that carries a member (deploy add created both clusters,
deploy del removed both ledger records, but only the member's cluster was
deleted; the root's stayed up).
Reproduction (live, disposable)
Two deploy:kindcluster deploys sharing the plugin-kube candy — a root and a
deploy-level member:
charly -C . deploy add lk-root -y # creates clusters lk-root AND lk-member
charly -C . deploy del lk-root -yResult:
Removed external deploy 746b9f5acea5ca6e (kindcluster) # lk-root
Removed external deploy c83d0071e0d30edd (kindcluster) # lk-member
…yet:
$ KIND_EXPERIMENTAL_PROVIDER=podman kind get clusters
check-kc
lk-root ← LEAKED (member cluster lk-member was deleted)
Root cause
The ledger stores one candy record with a refcounted deployed_by set and a
single reverse_ops list:
ledger:
deploys:
746b9f5acea5ca6e: { deploy_id: 746b9f5acea5ca6e, image: lk-root, target: kindcluster, candy: [plugin-kube] }
c83d0071e0d30edd: { deploy_id: c83d0071e0d30edd, image: lk-member, target: kindcluster, candy: [plugin-kube] }
candies:
plugin-kube:
deployed_by: [746b9f5acea5ca6e, c83d0071e0d30edd]
reverse_ops:
- kind: plugin-script
script: KIND_EXPERIMENTAL_PROVIDER='podman' kind delete cluster --name 'lk-member' >/dev/null 2>&1 || true; # ← only lk-member'sThe second deploy's BuildDeployReply(reverseOps, …) write replaced the
first's reverse_ops on the shared plugin-kube record. Refcounting correctly
keeps the candy alive until the last deploy is removed — but the op that then
replays is the overwritten one, so the earlier deploy's resource leaks.
kind delete cluster is per cluster name, so for kindcluster the op is
inherently per-deploy-instance and the shared-single-op model is wrong for it.
A member-less single kindcluster deploy cleans up fine (nothing overwrites), which
is why the merged check-kindcluster bed never showed this.
Impact
Any two+ deploys of the same substrate candy whose reverse-op is
per-deploy-instance leak resources on teardown. For deploy:kindcluster that is
a running kind cluster + node container + kubeconfig context per extra
deploy. Also blocks any kindcluster bed with a member from being a clean R10
(the shape used to reproduce charly#680).
Fix direction (owner: sdk ledger)
reverse_ops must be keyed per deploy (or the candy record must keep a
per-deploy_id op set), so teardown replays every contributing deploy's op
when the refcount empties — mirroring how deployed_by already refcounts.
kindClusterTeardown's current >/dev/null 2>&1 || true also hides such
failures (no signal when a cluster is not deleted).
Environment
Arch/CachyOS, rootless podman; charly built from the worktree at
2026.269.0721 + plugin-fleet fix/ledger-lock-inherit. All clusters created
during the repro were torn down; no residue left.
Activity
aitrawog commentedon Oct 7, 2026
RESOLVED — the defect is fixed in the producer, pinned by the consumer, and the fix is proven load-bearing.
opencharly/sdk#306— "fix(ledger): accumulate reverse ops for a shared candy (charly#687)", merged 2026-09-26,90d0d627. An earlier triage pass recorded "no PR references kindcluster: candy-scoped reverse_ops overwrite leaks one cluster per extra deploy of the candy #687"; that was a false negative (the search did not reach the sdk repo) and is corrected here.charly'sorigin/maincharly/go.modresolvesgithub.com/opencharly/sdk v0.2026280.1251, later than that merge.teardown; artifact/tmp/evidence-687-mutant.log, read by the Lead): the pinned artifact's own regression tests pass on a throwaway copy of[email protected]—TestAcquireLedgerLock_ExcludesPeers,TestAddCandyDeployment_MergesReverseOps,TestAddCandyDeploymentVia_MergesReverseOps,TestMergeReverseOps— and reverting both ledger write sites to pre-kindcluster: candy-scoped reverse_ops overwrite leaks one cluster per extra deploy of the candy #687 replacement semantics makes the two merge tests FAIL with exactly this issue's shape:i.e.
plugin-kube.reverse_opsretained only the later deploy's op and droppedcluster --name a— the leak this issue reports.|| trueatcandy/plugin-kube/kindcluster.go:398was examined and is documented in that file as deliberate (kind delete clusteris idempotent on a missing cluster); no mechanism was found by which a cluster survives while the error is swallowed. Claiming one without a repro would be a guard against an unproven danger. If a live two-cluster run ever shows that swallow hiding a real failure, that is its own observation with its own evidence.Agent:
dsh-issue-triageAssisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system; the pinned artifact's regression suite executed, with a mutant control proving the fix's necessity)