Skip to content

evetest: hold the purge end state across a reboot - #6280

Merged
eriknordmark merged 1 commit into
lf-edge:masterfrom
eriknordmark:purge-fix-validation
Sep 16, 2026
Merged

eriknordmark merged 1 commit into
lf-edge:masterfrom
eriknordmark:purge-fix-validation

Conversation

@eriknordmark

@eriknordmark eriknordmark commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Description

A purge submitted while the node is down is already covered by
TestVMAppPurgeAfterPowerCycle (#6257), but only up to the moment it settles.
The field failure that coverage comes from has a second half: a further reboot
adds another copy of the volume without removing the first. Reaching the right
end state once is not the same as holding it across a boot, and nothing
currently checks the difference.

evetest: hold the purge end state across a reboot adds a phase that
reboots the node once the purge has settled and re-runs the existing end-state
assertions unchanged. Re-using them rather than writing new ones is the point:
the decisive check on the kube path — exactly one VMIRS named for the new
generation — is precisely what a resurrected generation would break, and the
persisted purge counter must not have moved either.

The same commit adds a POWER_CUT_METHOD parameter selecting how the node is
taken down while the purge is submitted. Alongside the existing power cut,
controller-reboot uses a reboot command from the controller: zedagent stops
parsing a configuration as soon as it sees a new reboot counter, so a purge
submitted after that command is deferred to the next boot just as an outage
defers it. That reaches the same window through configuration parsing rather
than by pulling the power, so it also covers a purge deferred by an orderly
reboot rather than by a crash.

controller-reboot is the stronger of the two methods

Worth knowing when deciding which method CI should run. On the power-cycle
path, the phase-5 waits are satisfied by state cached from before the outage —
WaitForClusterNodeIsReady returns on its GetClusterInfo() pre-check and
WaitUntilAppIsRunning on its snapshot replay — so both return within a second
of the node coming back and assert nothing. A controller reboot is orderly, so
the newest state the controller holds is HALTED, and the same waits genuinely
have to observe the app return.

That makes phase 5's doc comment ("a purge wedged on a volume-ref removal never
gets past this point, so the wait is itself an assertion") true on the
controller-reboot path and aspirational on the power-cycle one. It also moves
where the time is spent: the purge assertions that follow take about four
minutes of a five-minute budget after a power cut, and three seconds after a
controller reboot, because in the latter case phase 5 has already absorbed the
convergence.

Notes for review

assertNoOrphanedPVCs is commented out on Kubevirt in master, because
sweepStaleGenerations deletes the old VMIRS and its pod but not its PVC. The
reboot phase added here does not depend on that assertion, but a stale PVC is
the other half of the same story and is still uncovered.

The reboot phase gets its own budget, postRebootEndStateTimeout, rather than
reusing purgeEndStateTimeout. It has to clear pillar's boot-retry interval
(timer.boot.retry, default ten minutes): a reboot can land domainmgr's
workload create before kubevirt's virt-api is serving, and the validating
webhook then refuses the connection, which marks the domain BootFailed.
maybeRetryBoot leaves it that way until the interval elapses, so a budget
below ten minutes reports that transient race as a purge that did not hold.
This was observed once on a device — the app sat BROKEN with
BootFailed=true and TriedCount=1 for the full five minutes the old budget
allowed. Whether domainmgr should react to an unreachable webhook faster than
the generic boot-retry timer is a separate question, and this test only needs
to not misreport it.

How to test and validate this PR

GOWORK=off go vet ./tests/... and GOWORK=off go test -count=1 -run '^$' ./tests/... from evetest/. (go build ./tests/... compiles nothing there —
every package under tests/ is test-files-only.)

On a device, make evetest NAME=TestVMAppPurgeAfterPowerCycle, or the whole
NAME=TestAppsSuite, where it already runs last. Add
POWER_CUT_METHOD=controller-reboot for the new deferral path.

Run on amd64 against 0.0.0-master-baseline-f9408900, a master build carrying
#6257:

Hypervisor POWER_CUT_METHOD Result
kubevirt power-cycle (default) pass, 988 s
kubevirt controller-reboot pass, 942 s

Margins on that hardware, against the budgets in purge_helpers_test.go:
the controller reboot was observed at 141 s and 175 s against
deviceRebootTimeout's five minutes, which is the tightest of the new budgets;
the reboot in the new phase at 74–86 s; the new phase's assertions at 86 s.

Two limits on what those runs establish. The image is 70 commits behind current
master, ten of them on the purge and kubevirt paths, so it does not exercise
today's code on those paths. And postRebootEndStateTimeout is sized from
timer.boot.retry rather than validated against the failure it exists for: the
webhook race did not recur on the passing run, which therefore says nothing
about the raised budget. Not run on arm64.

Changelog notes

No user-facing change — test and test-harness only.

PR Backports

Not applicable.

Checklist

  • I've provided a proper description
  • I've added the proper documentation
  • I've tested my PR on amd64 device
  • I've tested my PR on arm64 device
  • I've written the test verification instructions
  • I've set the proper labels to this PR
  • I've added a reference link to the original PR
  • PR's title follows the template
  • I've checked the boxes above, or I've provided a good reason why I didn't

Reasons for the unchecked boxes: no documentation change — this is test and
harness code only. Not run on arm64.

@eriknordmark
eriknordmark force-pushed the purge-fix-validation branch 2 times, most recently from 8302b68 to e83ae8d Compare August 7, 2026 20:51
@codecov

codecov Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 26.46%. Comparing base (f7c7b5f) to head (49909cc).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6280      +/-   ##
==========================================
+ Coverage   26.15%   26.46%   +0.31%     
==========================================
  Files         514      524      +10     
  Lines       94703    96419    +1716     
==========================================
+ Hits        24771    25522     +751     
- Misses      68021    68803     +782     
- Partials     1911     2094     +183     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@eriknordmark
eriknordmark force-pushed the purge-fix-validation branch 2 times, most recently from 4d56974 to 9f206f8 Compare August 20, 2026 08:50
@eriknordmark
eriknordmark marked this pull request as ready for review August 20, 2026 08:51
@eriknordmark
eriknordmark marked this pull request as draft August 20, 2026 08:57
@eriknordmark eriknordmark changed the title evetest: cover an app purge interrupted by power loss evetest: hold the purge end state across a reboot Aug 20, 2026
@eriknordmark
eriknordmark force-pushed the purge-fix-validation branch 2 times, most recently from e37c364 to 45adfdb Compare September 9, 2026 14:28
@eriknordmark
eriknordmark marked this pull request as ready for review September 9, 2026 14:31
@eriknordmark eriknordmark added the testing New test or test framework changes label Sep 12, 2026
@rene

rene commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

@claude

@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @rene's task in 3m 19s —— View job


Review complete

  • Read the changed files and surrounding context
  • Analyze the new LocalRawDiskImage type
  • Analyze the reboot phase and controller-reboot method
  • Post review feedback

I reviewed the diff against origin/master, plus the harness plumbing it relies on (WatchDeviceInfo, rebootAndWait, RequestReboot/SoftReboot, SubscribeToDeviceInfoMsgs, CreateBlankImageFile, the ApplicationImageStorage interface, and matchers.SatisfyPredicate).

Overall: solid, well-documented test code. The controller-reboot deferral path is correct: the reboot-evidence wait uses the standard Eventually(...).Should(Receive(SatisfyPredicate(...))) pattern (subscription established before the trigger so the post-boot message can't be missed), the predicate is nil-safe on GetLastRebootTime(), and the incExpectedRebootCount bookkeeping balances against actual reboots on both branches. Phase 7 correctly uses the cooperative SoftReboot(true) (which can rely on LastRebootTime being republished, unlike the hard power-off), and re-uses the phase-6 assertions verbatim as intended. The postRebootEndStateTimeout sizing against timer.boot.retry is well-justified in the comment.

I posted two minor inline notes (no correctness bugs found):

  1. WatchDeviceInfo is subscribed unconditionally but only consumed on the controller-reboot path — benign, but cleaner to scope it to that branch.
  2. LocalRawDiskImage has no caller, so its toProto path is compiler-checked only; consider landing it with its first user.

Neither is blocking. The clock-sync assumption in the reboot-evidence predicate matches the existing rebootAndWait behavior, so it's not a new concern.
· branch purge-fix-validation

Comment on lines +256 to +259
// Subscribe before the node goes down, so the first post-boot info message
// cannot be missed while the controller-reboot variant waits for it.
devUpdates, stopDevWatch := device.WatchDeviceInfo()
defer stopDevWatch()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: this watcher is only consumed in the controller-reboot branch, but it's set up unconditionally. In the power-cycle branch devUpdates is never read, so its 100-slot channel fills and the forwarding goroutine (plus the underlying admin HTTP info stream) sits blocked until the deferred stopDevWatch() at the very end of the test.

Per-subscription isolation in adam.go means it can't stall the other subscribers, and at the ZiDevice publish rate it won't actually overflow, so this is benign — but it's needless for the power-cycle path. Cleaner to scope the subscribe/defer inside the powerCutControllerReboot case where it's the only consumer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — the subscribe and its defer are now inside the controller-reboot case.

Comment thread evetest/devconfig.go Outdated
Comment on lines +1359 to +1361
// toProto generates the raw disk image, publishes it on the image server and
// converts the reference into EVE protobuf ContentTree + DatastoreConfig.
func (image LocalRawDiskImage) toProto(th *TestHarness, log *logrus.Entry,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LocalRawDiskImage has no caller in this PR (acknowledged in the description), so its toProto path — the raw-disk generation, MaxDownloadBytes/SHA wiring, and delegation to HTTPStorage — is only checked by the compiler, never actually driven against a device. Adding unused harness API tends to bit-rot before its first real user. Given it's independent of the purge fix and you already offered to drop it, I'd suggest landing it in the PR that first uses it rather than as speculative groundwork here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eriknordmark Agree with Claude. Let's remove it if not used or move it to another PR where it belongs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped — the LocalRawDiskImage commit is out of this PR, so the diff is now just the test and its helper. It will come back in the PR that first uses it (the power-loss purge test).

A purge submitted while the node is down is already covered up to the moment
it settles. The field failure that coverage comes from has a second half: a
further reboot adds another copy of the volume without removing the first, so
reaching the right end state once is not the same as holding it.

The node is now rebooted again once the purge has settled, and the end-state
assertions run again unchanged. Reusing them is the point -- the decisive
check on the kube path, exactly one VMIRS named for the new generation, is
what a resurrected generation would break, and the purge counter must not
have moved either.

A POWER_CUT_METHOD parameter also selects how the node is taken down while
the purge is submitted. Alongside the existing power cut, controller-reboot
uses a reboot command from the controller: zedagent stops parsing a
configuration as soon as it sees a new reboot counter, so a purge submitted
after that command is deferred to the next boot just as an outage defers it.
That reaches the same window through configuration parsing rather than by
pulling the power, and so also covers a purge deferred by an orderly reboot.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@eriknordmark

Copy link
Copy Markdown
Contributor Author

Rebased on master.

On the red Eden job: the failing script is ctrl_encrypt_cert_change — an app not reaching RUNNING after a controller certificate rotation, with SenderStatusCertMiss on the cipher path. (The other FAIL in that log is fail_test, the escript harness asserting on its own failure handling.) This PR now touches only evetest/tests/apps/, which Eden does not run.

@eriknordmark

Copy link
Copy Markdown
Contributor Author

The CVE Watch Scan failure is infrastructure: the scan clones gitlab.alpinelinux.org/alpine/aports to build the Alpine package DB, and that clone returns HTTP 418 (Failed to clone aports repository → Failed to build Alpine package info for v3.22.0). It is failing the same way on every PR right now.

@eriknordmark
eriknordmark merged commit 3ac8734 into lf-edge:master Sep 16, 2026
53 of 56 checks passed
@eriknordmark
eriknordmark deleted the purge-fix-validation branch October 8, 2026 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing New test or test framework changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants