Repository navigation
[17.0-stable] eve-k: fix purge leaving stale VMIRS generations and volume refs - #6357
Merged
Merged
Conversation
A purge must delete the previous generation of an app before it creates
the next one. In the kube path three defects stop this. The old VMIRS
then keeps running, and EVE reports the purge as complete.
1. Info() says a domain is gone when it only cannot see it.
Info() returns domainID 0 if it finds no replica on this node.
domainmgr copies that 0 into DomainStatus. zedmanager reads 0 as
"there is no domain", so it skips the teardown and releases the
purge. Info() now gets identity and existence from the cluster:
- domainID is workloadID(), a hash of the VMIRS metadata.uid. It was
rand.Uint32(), which has no relation to the cluster.
- Task() keeps the DomainStatus. The kube name now comes from the
status and not from the vmiList cache, which goes stale.
- Info() returns 0 only when the VMIRS is absent. If it cannot
confirm absence, it returns the last known id.
2. Nothing deletes an old generation after a reboot.
/run is tmpfs, so a reboot deletes the purge state. The VMIRS stays
in etcd. zedmanager finds no domain to halt and advances the counter,
so the new generation starts beside the old one. Start() now sweeps
first: it finds each older generation of the app in the cluster,
deletes it, and waits until the object and its pods are gone. The
sweep reads the cluster and does not need the old counter, so it
survives the reboot. If it cannot confirm that a generation is gone,
Start() fails. A failed start is safer than two generations that
share MACs, veth names and one RWO disk.
3. zedmanager waits for ever for a volume-ref removal.
On a purge, doInstall parks the old VolumeRefStatus and waits for
volumemgr to confirm the delete. If volumemgr has no live status for
that reference in this boot, the confirmation never comes. The app
stays in DownloadAndVerify and never asks for the new volume.
zedmanager now looks at volumemgr's live status first, and drops the
reference if it is already absent.
Each Kubernetes request that this change adds now has a deadline of
kubeapi.KubeAPITimeout, with the apiCtx helper. domainmgr calls Info on a
timer of 9 to 30 seconds and calls Start directly, and the watchdog of
zedbox restarts the device if that handler stops to report. A request
without a deadline on those paths can therefore stop the node. With a
deadline it fails, and Info reports UNKNOWN and keeps the id of the caller,
which is the contract on types.DomainStatus.DomainId. getVmirs already used
this same limit, so the new calls now match it.
Also in this change:
- StopReplicaVMI had an inverted IsNotFound test, so each successful
delete logged "Stop VMI Replicaset error <nil>" at error level. This
made a good teardown look like a bad one in the field. The return
values do not change.
- The kubevirt and k8s client constructors are now package-level vars.
The tests can then inject a fake client.
- Info() and sweepStaleGenerations() now call getConfig() themselves.
The receiver is a value, so a getConfig() call in a method they call
fills in a copy and leaves kubeConfig nil. A nil kubeConfig made
newKubevirtClient panic, which stopped zedbox and rebooted the node.
The client stubs in the tests now reject a nil config.
- docs/zedkube.md records what domainID means, what the sweep does, and
two gaps that stay open: the sweep does not delete the stale
generation's PVC, and it cannot run if a purge stops before Start().
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Andrew Durbin <andrewd@zededa.com>
(cherry picked from commit 9c2eecf)
andrewd-zededa
requested review from
eriknordmark,
rene,
rucoder and
shjala
as code owners
August 19, 2026 21:24
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 17.0-stable #6357 +/- ##
===============================================
+ Coverage 20.65% 21.37% +0.72%
===============================================
Files 506 518 +12
Lines 93032 94994 +1962
===============================================
+ Hits 19214 20306 +1092
- Misses 72219 72862 +643
- Partials 1599 1826 +227 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Description
Backport of #6257
Partial backport: the pillar fix only. The two evetest commits from the
original PR are not included — see "Scope" below.
Purge leaves the old app generation running on the kube path
A purge must delete the app's previous generation before it creates the
new one. On the kube path it does not: the old VMIRS keeps running, and
EVE reports the purge complete anyway.
Root cause (three defects, all in
pkg/pillar)Info()reports "gone" when it only can't see the domain. Itreturned domain ID 0 whenever it found no replica on this node.
domainmgrcopies that 0 intoDomainStatus;zedmanagerreads 0 as"no domain," skips the teardown, and releases the purge anyway.
Info()now gets identity and existence from the cluster instead ofa random ID, and returns 0 only when the VMIRS is confirmed absent —
never when it merely can't confirm one way or the other.
Nothing deletes the old generation after a reboot.
/runistmpfs, so a reboot drops the purge state pillar was tracking, but the
VMIRS survives in etcd.
zedmanagerfinds no local domain to halt,advances the counter anyway, and a new generation starts beside the
old one.
Start()now sweeps the cluster first: it finds every oldergeneration, deletes it, and confirms the object and its pods are
gone before proceeding. A failed sweep fails the start — safer than
two generations sharing MACs, veth names, and one RWO disk.
zedmanagercan wait forever for a volume-ref removal. A purgeparks the old
VolumeRefStatusand waits forvolumemgrto confirmthe delete. If
volumemgrhas no live status for that reference inthe current boot, the confirmation never arrives, and the app is
stuck in
DownloadAndVerifyforever.zedmanagernow checksvolumemgr's live status first and drops the reference if it'salready gone.
Scope of this backport
Only
pillar: keep purges from leaving the old app generation behind(9c2eecf) is backported. It cherry-picks
cleanly onto 17.0-stable with no adaptation.
The original PR's two evetest commits are omitted because they cannot be
cherry-picked to this branch: the evetest framework here is a different
generation (
evetest/VERSIONv0.0.1 vs 1.4 on master, with 79 evetestcommits on master not present on 17.0-stable). Both commits modify files
that do not exist on this branch —
evetest/tests/apps/testsuite_test.go(the whole
tests/apps/suite is absent) and threeevetest/tests/cluster/files — and the new tests call harness helpersthis branch's
edgedevice.go/harness.godo not have. Porting thatpurge coverage to the v0.0.1 harness would be a hand-written change, not
a backport, so it is deliberately left out of this PR.
PR dependencies
None. This does not conflict with #6353 (the #6100 backport); the two
were verified to apply cleanly in either order.
How to test and validate this PR
The automated purge tests are not available on this branch (see Scope),
so validate manually on an eve-k device — purging a container app, which
runs in a VMIRS via a shim VM:
one volume must exist before and after, and the survivor must be named
for the new generation.
then power it back on. This reproduces the failure customers saw. On
coming back up there must be exactly one VMIRS (the new generation),
no leftover PVC from the old one, and the app must reach running
rather than sticking in
DownloadAndVerify.Useful checks on the device:
A kvm-hypervisor purge across a power cycle is a useful control: a kvm
domain is a local qemu process with no cluster-side object to lose track
of, so the duplicate-generation defect is structurally impossible there.
Unit coverage picked up with the fix:
go test -tags k ./cmd/zedmanager/... ./hypervisor/...(includes the newupdatestatus_test.go,kubevirt_staleness_test.go,kubevirt_identity_test.go,kubevirt_info_test.goand others).Changelog notes
Fixes a bug on eve-k (kubevirt hypervisor) where purging an application around a
device reboot could leave a duplicate/stale VM instance running alongside the new
one, or leave the purge stuck indefinitely instead of completing. No other
user-facing changes.
PR Backports
This is the backport
Checklist
For backport PRs (remove it if it's not a backport):
And the last but not least:
check them.
Please, check the boxes above after submitting the PR in interactive mode.