fix(k3s): detect out-of-band child-VM deletion + skip cache for composites (bug 1)#115
Merged
Conversation
…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.
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.
Fixes Bug 1 from the 2026-07-07 worker recovery: after a child VM was deleted outside openctl, the Cluster read
Readyand a re-apply did nothing.Two causes → two coordinated fixes
Gettrusted the stale child list. It synthesized observed node counts from the persistedchildrenlist without checking the VMs exist — so a deleted worker was still counted and no drift surfaced.applyObservedCountsnow verifies each child VM via the VM provider (vmChildExists): a definitiveNotFounddrops 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.input+refshashes 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-runsprovider.Apply); the existing atomic cache-hit test still passes. Full suite +-race, lint/staticcheck/modernize clean,make buildgreen.Bug 2 (Plan-based count-up on legacy pre-
K3sNodeclusters) is the next PR.