Skip to content

fix(k3s): detect out-of-band child-VM deletion + skip cache for composites (bug 1)#115

Merged
astrojerms merged 1 commit into
mainfrom
fix/cluster-child-drift
Jul 8, 2026
Merged

fix(k3s): detect out-of-band child-VM deletion + skip cache for composites (bug 1)#115
astrojerms merged 1 commit into
mainfrom
fix/cluster-child-drift

Conversation

@astrojerms

Copy link
Copy Markdown
Owner

Fixes Bug 1 from the 2026-07-07 worker recovery: after a child VM was deleted outside openctl, the Cluster read Ready and a re-apply did nothing.

Two causes → two coordinated fixes

  1. Get trusted the stale child list. It synthesized observed node counts from the persisted children list without checking the VMs exist — so a deleted worker was still counted and no drift surfaced. applyObservedCounts now verifies each child VM via the VM provider (vmChildExists): a definitive NotFound drops it from the count (drift shows); a transient error is treated as "exists" so a provider blip doesn't fabricate drift and trigger destructive convergence.
  2. The verifying-trace cache short-circuited re-applies. With the manifest unchanged, input+refs hashes matched → cache hit → reconciliation skipped, so even fixed drift detection couldn't remediate. The dispatcher now skips the verifying-trace cache for composite (Planner) providers — a composite converges over children that drift independently of the manifest hash, which an input-hash cache can't capture. A Cluster re-apply always reconciles (apply-existing is idempotent → converged cluster is a fast no-op). Atomic resources keep the cache.

Tests

TestGetDetectsDeletedChildVM (worker in state, VM gone → count 0), TestVerifyingCacheSkippedForComposite (identical re-apply of a Planner re-runs provider.Apply); the existing atomic cache-hit test still passes. Full suite + -race, lint/staticcheck/modernize clean, make build green.

Bug 2 (Plan-based count-up on legacy pre-K3sNode clusters) is the next PR.

…sites

Bug 1 from the 2026-07-07 worker recovery: after a child VM was deleted
outside openctl, the Cluster read Ready and a re-apply did nothing.

Two coordinated causes, two fixes:

1. Cluster Get synthesized observed node counts from the persisted
   children list without checking the VMs exist, so a deleted worker was
   still counted and no drift surfaced. applyObservedCounts now verifies
   each child VM via the VM provider (vmChildExists): a definitive
   NotFound drops the child from the count (drift shows); a transient
   error is treated as "exists" so a provider blip does not fabricate
   drift and trigger destructive convergence; a nil VM provider (tests)
   trusts the state list.

2. The verifying-trace cache short-circuited re-applies: with the
   manifest unchanged, input+refs hashes matched and the apply was a
   cache hit that skipped reconciliation entirely -- so even the fixed
   drift detection could not be remediated. The dispatcher now skips the
   verifying-trace cache for composite (Planner) providers: a composite
   converges over children that drift independently of the manifest
   hash, which an input-hash cache cannot capture. A Cluster re-apply
   always reconciles; apply-existing is idempotent so a converged
   cluster is a fast no-op. Atomic resources keep the cache.

Tests: TestGetDetectsDeletedChildVM (worker in state, VM gone -> count
0), TestVerifyingCacheSkippedForComposite (identical re-apply of a
Planner re-runs provider.Apply); the existing atomic cache-hit test
still passes.
@astrojerms astrojerms merged commit 40433d1 into main Jul 8, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant