Skip to content

eve-k volumemgr: reclaim orphaned PVCs after a stale generation is swept - #6406

Merged
rene merged 3 commits into
lf-edge:masterfrom
andrewd-zededa:eve-k-purge-cleanup-part2
Oct 30, 2026
Merged

rene merged 3 commits into
lf-edge:masterfrom
andrewd-zededa:eve-k-purge-cleanup-part2

Conversation

@andrewd-zededa

@andrewd-zededa andrewd-zededa commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Description

pillar: reclaim orphaned PVCs after a stale generation is swept — the
fix. sweepStaleGenerations (added in #6257) deletes a stale purge
generation's VMIRS and its pod, but not its PVC. When a purge is issued while
the node is down, the node boots straight into the new generation's config, so
volumemgr never creates a VolumeStatus for the old generation and its normal
delete path never runs. The old PVC stays in the cluster and nothing points at
it.

This adds gcPVCs to volumemgr's GC tick. The safety question is which PVCs it
must keep. The PVC list is cluster-wide, but a controller need not send every
volume to every node of a cluster, and an app-free standalone volume can be
present on some nodes only. A node can therefore list a live PVC that it has no
record of, so "no VolumeStatus names it" is not enough to delete it.
gcPVCs deletes a PVC only when all of these hold:

  • this node's config holds the same volume at a newer generation;
  • no VolumeConfig or VolumeStatus on this node names the PVC's own
    generation, which covers a purge in flight and a create still deferred;
  • this node owns the volume (IsReplicated false), or is its backup DNID
    while the designated node is down.

A PVC for a volume this node does not know is never deleted. The cost is that
a volume removed from the config entirely while its node was down keeps its
PVC, which is the safe failure.

A PVC name carries one number, but a volume has two counters. The comparison
uses GenerationCounter + LocalGenerationCounter, the same sum Key() and
GetPVCName() use. The file and ZFS GC (gcVolumes) is unchanged.

gcPVCs runs on volumemgr's main loop, so it lists PVCs with a 5s deadline;
a missed pass is retried on the next tick. GetPVCList now takes its deadline
from the caller, and the startup scan keeps the 30s kubeAPITimeout.
DeletePVC gets the same 30s deadline; it had none.

evetest: list app-namespace objects and add cluster blank volumes —
framework only.

  • EdgeDevice.KubectlListNames moves the PVC listing out of tests/apps.
  • EdgeClusterConfig.AddBlankVolume adds one standalone volume to selected
    nodes, can leave nodes out the way a controller may, and can start the volume
    at a later generation or under a UUID the test chose.
  • EdgeCluster.WaitForFreshNodesReady counts only cluster reports that arrive
    after the call. After a power-off, the last cached report still shows the
    node Ready, so WaitUntilNodesAreReady can return before the node has
    booted. This replaces the upgrade test's own copy of the same wait.

evetest: cover PVC garbage collection, on one node and across a cluster —
new coverage, plus a fix to an assertion that could pass without checking
anything.

assertNoOrphanedPVCs asked only that each PVC present was expected. An empty
list satisfies that, and listPVCNames returned an empty list on any kubectl
error, so the assertion passed while k3s was down. It now fails on a kubectl
error and also requires a volume in CREATED_VOLUME state to still have its
PVC. TestVMAppPurgeAfterPowerCycle re-enables it with timer.gc.vdisk at its
60s floor.

TestClusterPVCGCDeletesOnlyOrphans replaces the earlier cluster test, which
never produced a real orphan. On three nodes it sets up:

  • a standalone persistent volume, sent to two of the three nodes, with no
    designated node and no app;
  • an orphan PVC created under a volume no node has yet, so every node must keep
    it. The volume is then sent at generation 1, and its designated node deletes
    the orphan;
  • with the designated node powered off, the app volume's superseded PVC, which
    the backup DNID deletes.

Per-node logs show which node deleted each orphan. The persistent PVC survives
on every node throughout, including the node with no config for it. Each state
has a checkpoint: persistent-volume-exists, orphan-exists,
orphan-cleaned-up, persistent-volume-not-cleaned-up,
backup-orphan-exists, backup-orphan-cleaned-up, and
persistent-volume-not-cleaned-up-after-outage.

PR dependencies

None. #6257 is already merged; this completes the PVC half of that sweep.

How to test and validate this PR

Automated coverage:

# volumemgr unit tests for the GC rule
make -C pkg/pillar test TESTPKGS=./cmd/volumemgr/... TESTRUN=PVC

# the cluster rule: only orphans are deleted, by the DNID or backup DNID
make evetest NAME=TestClusterPVCGCDeletesOnlyOrphans

# the single-node reclaim path, with the hardened orphan assertion, and its
# KVM control
EVETEST_HYPERVISOR=kubevirt make evetest NAME=TestVMAppPurgeAfterPowerCycle
EVETEST_HYPERVISOR=kvm make evetest NAME=TestVMAppPurgeAfterPowerCycle

Manual check on an EVE-k node:

  1. Deploy an app and purge it once. Its volume's PVC is now
    <volume-uuid>-pvc-1.
  2. Create a PVC named <volume-uuid>-pvc-0 in the eve-kube-app namespace.
    This stands for the orphan a purge leaves when the node was down.
  3. Within one GC tick (timer.gc.vdisk/10, six minutes by default), volumemgr
    logs this at info level and the PVC goes away:
    gcPVCs: deleting PVC <volume-uuid>-pvc-0, superseded by a newer generation of volume <volume-uuid>
  4. Every other PVC stays, and the app stays RUNNING.

Validation status:

  • The volumemgr and kubeapi unit tests pass in the pillar test container.
  • TestClusterPVCGCDeletesOnlyOrphans passed on a 3-node EVE-k amd64
    cluster. Every node kept both orphans until it was allowed to delete them, and
    kept the persistent PVC throughout, including the node with no config for it.
    The DNID deleted its orphan once the volume was sent, and the backup DNID
    deleted the other within three minutes of the DNID powering off. Both orphans
    were bound, and the backup orphan's PV was removed with it. The persistent
    PVC survived both deletes, an app purge, and the outage.
  • TestVMAppPurgeAfterPowerCycle passed on EVE-k amd64 and on KVM amd64,
    each within the 5-minute reclaim bound. On EVE-k, gcPVCs deleted the purged
    generation's PVC, and the live PVC stayed.

Changelog notes

Fixed a bug where an EVE-K node kept the old disk of an application purged
while the node was down. The stale PersistentVolumeClaim stayed in the cluster
and consumed storage, although nothing used it. EVE now reclaims it, and never
removes a volume's disk that the node has no record of.

PR Backports

  • 17.0-stable: To be backported.
  • 16.0-stable: No, as the feature is not available there.
  • 14.5-stable: No, as the feature is not available there.
  • 13.4-stable: No, as the feature is not available there.

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

And the last but not least:

  • I've checked the boxes above, or I've provided a good reason why I didn't
    check them.

Please, check the boxes above after submitting the PR in interactive mode.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 29.01%. Comparing base (8d07232) to head (696c3f2).
⚠️ Report is 52 commits behind head on master.

Files with missing lines Patch % Lines
pkg/pillar/kubeapi/vitoapiserver.go 0.00% 7 Missing ⚠️
pkg/pillar/cmd/volumemgr/initialvolumestatus.go 83.33% 5 Missing and 1 partial ⚠️
pkg/pillar/cmd/volumemgr/volumemgr.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6406      +/-   ##
==========================================
+ Coverage   28.48%   29.01%   +0.53%     
==========================================
  Files         540      551      +11     
  Lines       98258    99894    +1636     
==========================================
+ Hits        27985    28987    +1002     
- Misses      68003    68683     +680     
+ Partials     2270     2224      -46     

☔ 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.

@andrewd-zededa
andrewd-zededa force-pushed the eve-k-purge-cleanup-part2 branch from d86e9ba to 679921b Compare August 25, 2026 19:51
@andrewd-zededa

Copy link
Copy Markdown
Contributor Author
$ EVETEST_EVE_VERSION=0.0.0-pr-6406-679921bd EVETEST_PAUSE_ON_FAILURE=true EVETEST_HYPERVISOR=kubevirt EVETEST_LOG_LEVEL=debug EVETEST_COLLECT_ARTIFACTS=/tmp/evetest-pr${PR}-logs make evetest NAME=TestVMAppPurgeAfterPowerCycle
...
Starting test: TestVMAppPurgeAfterPowerCycle
=== RUN   TestVMAppPurgeAfterPowerCycle
...
HARNESS  time="2026-08-25T20:23:31Z" level=info msg="BuildImage "lfedge/eve:0.0.0-pr-6406-679921bd-k-amd64" succeeded (docker image was already present)."
...
HARNESS  time="2026-08-25T20:32:35Z" level=info msg="App "84e061fa-e5fe-4b5f-9d1d-c967d5c10791" (purge-app) on device "edge-dev" is RUNNING"
...
BROKER   time="2026-08-25T20:32:36Z" level=info msg="Successfully powered OFF EVE device "edge-dev""
TEST     time="2026-08-25T20:32:36Z" level=info msg="Powering device "edge-dev" back on"
...
HARNESS  time="2026-08-25T20:34:10Z" level=info msg="Waiting for app "84e061fa-e5fe-4b5f-9d1d-c967d5c10791" on device "edge-dev" to reach RUNNING state..."
HARNESS  time="2026-08-25T20:34:10Z" level=info msg="Device edge-dev state changed: BOOTING -> ONLINE"
HARNESS  time="2026-08-25T20:34:10Z" level=info msg="App "84e061fa-e5fe-4b5f-9d1d-c967d5c10791" (purge-app) on device "edge-dev" currently in state INITIAL; waiting for it to reach RUNNING"
HARNESS  time="2026-08-25T20:34:59Z" level=info msg="App "84e061fa-e5fe-4b5f-9d1d-c967d5c10791" (purge-app) on device "edge-dev" state changed to DOWNLOAD_STARTED (100%)"
...
HARNESS  time="2026-08-25T20:37:02Z" level=info msg="App "84e061fa-e5fe-4b5f-9d1d-c967d5c10791" (purge-app) on device "edge-dev" is RUNNING"
...
--- PASS: TestVMAppPurgeAfterPowerCycle (936.13s)
PASS

@andrewd-zededa andrewd-zededa added stable Should be backported to stable release(s) next-17.0.x-rc PR must be present in the next 17.0.x-lts release labels Aug 25, 2026
@andrewd-zededa

Copy link
Copy Markdown
Contributor Author
$ EVETEST_EVE_VERSION=0.0.0-pr-6406-679921bd EVETEST_PAUSE_ON_FAILURE=true EVETEST_HYPERVISOR=kubevirt EVETEST_LOG_LEVEL=debug EVETEST_COLLECT_ARTIFACTS=/tmp/evetest-pr${PR}-logs make evetest NAME=TestClusterPVCGCPreservesLiveVolumes
...
=== RUN   TestClusterPVCGCPreservesLiveVolumes
...
HARNESS  time="2026-08-25T21:18:09Z" level=info msg="BuildImage "lfedge/eve:0.0.0-pr-6406-679921bd-k-amd64" succeeded (docker image was already present)."
...
--- PASS: TestClusterPVCGCPreservesLiveVolumes (1584.73s)
PASS

@andrewd-zededa
andrewd-zededa marked this pull request as ready for review August 25, 2026 22:37
@andrewd-zededa
andrewd-zededa marked this pull request as draft August 25, 2026 23:34
eriknordmark added a commit to eriknordmark/eve that referenced this pull request Sep 3, 2026
…tusCtx

The reclaim test in lf-edge#6406 passes the context by address at every call
site, while initStatusCtx returns a pointer already. Taking its address
again yields **volumemgrContext and cmd/volumemgr stops compiling. Pass
the pointer straight through.

Branch-local: it belongs on lf-edge#6406 once that PR rebases onto current
master, not on this integration branch.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
eriknordmark added a commit to eriknordmark/eve that referenced this pull request Sep 3, 2026
…tusCtx

The reclaim test in lf-edge#6406 passes the context by address at every call
site, while initStatusCtx returns a pointer already. Taking its address
again yields **volumemgrContext and cmd/volumemgr stops compiling. Pass
the pointer straight through.

Branch-local: it belongs on lf-edge#6406 once that PR rebases onto current
master, not on this integration branch.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
eriknordmark added a commit to eriknordmark/eve that referenced this pull request Sep 8, 2026
…tusCtx

The reclaim test in lf-edge#6406 passes the context by address at every call
site, while initStatusCtx returns a pointer already. Taking its address
again yields **volumemgrContext and cmd/volumemgr stops compiling. Pass
the pointer straight through.

Branch-local: it belongs on lf-edge#6406 once that PR rebases onto current
master, not on this integration branch.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
eriknordmark added a commit to eriknordmark/eve that referenced this pull request Sep 8, 2026
…tusCtx

The reclaim test in lf-edge#6406 passes the context by address at every call
site, while initStatusCtx returns a pointer already. Taking its address
again yields **volumemgrContext and cmd/volumemgr stops compiling. Pass
the pointer straight through.

Branch-local: it belongs on lf-edge#6406 once that PR rebases onto current
master, not on this integration branch.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
eriknordmark added a commit to eriknordmark/eve that referenced this pull request Sep 8, 2026
…tusCtx

The reclaim test in lf-edge#6406 passes the context by address at every call
site, while initStatusCtx returns a pointer already. Taking its address
again yields **volumemgrContext and cmd/volumemgr stops compiling. Pass
the pointer straight through.

Branch-local: it belongs on lf-edge#6406 once that PR rebases onto current
master, not on this integration branch.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
eriknordmark added a commit to eriknordmark/eve that referenced this pull request Sep 17, 2026
…tusCtx

The reclaim test in lf-edge#6406 passes the context by address at every call
site, while initStatusCtx returns a pointer already. Taking its address
again yields **volumemgrContext and cmd/volumemgr stops compiling. Pass
the pointer straight through.

Branch-local: it belongs on lf-edge#6406 once that PR rebases onto current
master, not on this integration branch.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
eriknordmark added a commit to eriknordmark/eve that referenced this pull request Sep 17, 2026
Integration branch on master with the conversion chain (lf-edge#6530, lf-edge#6063, fork#6)
and the purge/PVC robustness set (lf-edge#6442, lf-edge#6406, lf-edge#6478). Records the tips each
piece was replayed from, the branch-local adapters that no PR carries, and the
storage-resizer content pin.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
eriknordmark added a commit to eriknordmark/eve that referenced this pull request Sep 17, 2026
…tusCtx

The reclaim test in lf-edge#6406 passes the context by address at every call
site, while initStatusCtx returns a pointer already. Taking its address
again yields **volumemgrContext and cmd/volumemgr stops compiling. Pass
the pointer straight through.

Branch-local: it belongs on lf-edge#6406 once that PR rebases onto current
master, not on this integration branch.

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

Copy link
Copy Markdown
Contributor

@andrewd-zededa Heads-up on a collision: #6478 adds RunKubectl and EVEKubeAppNamespace to evetest/edgedevice.go as well. Same method on *EdgeDevice, same const in package evetest, so whichever of us merges second is a redeclaration compile error rather than a textual conflict. We also both touch tests/apps/appworkload_helpers_test.go, tests/apps/purge_helpers_test.go and tests/cluster/testsuite_test.go.

Neither version is a superset of the other, so this needs a decision rather than a drop:

  • Yours bakes -n eve-kube-app into RunKubectl and takes the timeout from kubectlCommandTimeout. Mine passes the args through verbatim with a caller-supplied timeout, because two of its call sites need something else: -n longhorn-system delete pod -l app=csi-provisioner for the Longhorn CSI workaround, and tiebreaker_test.go's cluster-scoped get nodes … on its 2-minute budget.
  • Yours returns stdout and stderr separately and exports KubeItemList + KubectlListItems, which is the better half on decoding — one type reused across vmirs and pvc. Mine folds stderr into the error and leaves the list shapes local, so it has nothing to offer there. What it does add is ListAppVMIRS in the framework, where yours keeps listAppVMIRS unexported in tests/apps; that is what let the three-node purge test move into tests/cluster beside the others.

The union would be roughly RunKubectl(namespace, args string, timeout time.Duration) (stdout, stderr string, err error), with KubectlListItems and ListAppVMIRS layered on it. Events are the one thing neither covers — reason/message/involvedObject are not in KubeItemList — so the Longhorn workaround keeps decoding those itself either way.

Either order works from here: you fold it into #6406 and I rebase #6478 onto it, or I land the framework commit from #6478 ("evetest: reach kubectl through the framework", which is a separate commit for exactly this reason) and you drop yours. Do you have a preference? Worth settling soon — #6478 only compiles today because this one has not merged.

eriknordmark added a commit to eriknordmark/eve that referenced this pull request Sep 18, 2026
…tusCtx

The reclaim test in lf-edge#6406 passes the context by address at every call
site, while initStatusCtx returns a pointer already. Taking its address
again yields **volumemgrContext and cmd/volumemgr stops compiling. Pass
the pointer straight through.

Branch-local: it belongs on lf-edge#6406 once that PR rebases onto current
master, not on this integration branch.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 32182f2)
eriknordmark added a commit to eriknordmark/eve that referenced this pull request Sep 18, 2026
Both PRs promote the tests/apps kubectl plumbing into EdgeDevice, and
they picked different shapes: lf-edge#6406 bakes the app namespace into
RunKubectl and brings the richer KubeItemList a PVC's phase needs,
while lf-edge#6478 takes an explicit namespace plus a per-call timeout, which
the Longhorn workaround needs to reach longhorn-system. Keep lf-edge#6478's
runner as the only one and move KubectlListItems onto it; the local
copy in the app helpers is then dead and goes, as does the duplicate
cluster outage-threshold key lf-edge#6478 and lf-edge#6505 each declare.

Both PRs also pre-date master's volume-generation policy argument on
PurgeApplication, so their two cluster call sites pass the bump policy
they were written against.

Branch-local: it belongs on whichever of the two rebases last.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
eriknordmark added a commit to eriknordmark/eve that referenced this pull request Sep 18, 2026
Integration branch on master with the conversion chain (lf-edge#6530, lf-edge#6063, fork#6)
and the robustness set (lf-edge#6442, lf-edge#6406, lf-edge#6478, lf-edge#6505, lf-edge#6451, lf-edge#6590, lf-edge#6599).
Records the tips each piece was replayed from, where two PRs collide and which
side won, the branch-local adapters that no PR carries, and the
storage-resizer content pin.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
eriknordmark added a commit to eriknordmark/eve that referenced this pull request Sep 18, 2026
…tusCtx

The reclaim test in lf-edge#6406 passes the context by address at every call
site, while initStatusCtx returns a pointer already. Taking its address
again yields **volumemgrContext and cmd/volumemgr stops compiling. Pass
the pointer straight through.

Branch-local: it belongs on lf-edge#6406 once that PR rebases onto current
master, not on this integration branch.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 32182f2)
(cherry picked from commit 7b2d1da)
eriknordmark added a commit to eriknordmark/eve that referenced this pull request Sep 18, 2026
Both PRs promote the tests/apps kubectl plumbing into EdgeDevice, and
they picked different shapes: lf-edge#6406 bakes the app namespace into
RunKubectl and brings the richer KubeItemList a PVC's phase needs,
while lf-edge#6478 takes an explicit namespace plus a per-call timeout, which
the Longhorn workaround needs to reach longhorn-system. Keep lf-edge#6478's
runner as the only one and move KubectlListItems onto it; the local
copy in the app helpers is then dead and goes, as does the duplicate
cluster outage-threshold key lf-edge#6478 and lf-edge#6505 each declare.

Both PRs also pre-date master's volume-generation policy argument on
PurgeApplication, so their two cluster call sites pass the bump policy
they were written against.

Branch-local: it belongs on whichever of the two rebases last.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 2514912)
eriknordmark added a commit to eriknordmark/eve that referenced this pull request Sep 18, 2026
Integration branch on master with the conversion chain plus the fault-injection
stress harness (lf-edge#6530, lf-edge#6063, fork#6, fork#7) and the robustness set (lf-edge#6442,
lf-edge#6406, lf-edge#6478, lf-edge#6505, lf-edge#6451, lf-edge#6590, lf-edge#6599). Records the tips each piece was
replayed from, where two PRs collide and which side won, the branch-local
adapters that no PR carries, and the chaos storage-resizer content pin.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
eriknordmark added a commit to eriknordmark/eve that referenced this pull request Sep 24, 2026
…tusCtx

The reclaim test in lf-edge#6406 passes the context by address at every call
site, while initStatusCtx returns a pointer already. Taking its address
again yields **volumemgrContext and cmd/volumemgr stops compiling. Pass
the pointer straight through.

Branch-local: it belongs on lf-edge#6406 once that PR rebases onto current
master, not on this integration branch.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
eriknordmark added a commit to eriknordmark/eve that referenced this pull request Sep 24, 2026
Both PRs add a kubectl runner to EdgeDevice, so taking them together
leaves two RunKubectl methods and two EVEKubeAppNamespace constants on
one type and the framework stops compiling. Keep lf-edge#6478's runner, which
takes an explicit timeout, and move lf-edge#6406's KubectlListItems onto it;
the local copies in the apps tests go away with it.

Two of lf-edge#6406's call sites also predate master: SeparateClusterPort is a
function now, and PurgeApplication takes a volume-generation policy.

Branch-local: it belongs on lf-edge#6406 once that PR rebases onto current
master, not on this integration branch.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
eriknordmark added a commit to eriknordmark/eve that referenced this pull request Sep 24, 2026
…tusCtx

The reclaim test in lf-edge#6406 passes the context by address at every call
site, while initStatusCtx returns a pointer already. Taking its address
again yields **volumemgrContext and cmd/volumemgr stops compiling. Pass
the pointer straight through.

Branch-local: it belongs on lf-edge#6406 once that PR rebases onto current
master, not on this integration branch.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
eriknordmark added a commit to eriknordmark/eve that referenced this pull request Sep 24, 2026
Both PRs add a kubectl runner to EdgeDevice, so taking them together
leaves two RunKubectl methods and two EVEKubeAppNamespace constants on
one type and the framework stops compiling. Keep lf-edge#6478's runner, which
takes an explicit timeout, and move lf-edge#6406's KubectlListItems onto it;
the local copies in the apps tests go away with it.

Two of lf-edge#6406's call sites also predate master: SeparateClusterPort is a
function now, and PurgeApplication takes a volume-generation policy.

Branch-local: it belongs on lf-edge#6406 once that PR rebases onto current
master, not on this integration branch.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@andrewd-zededa

Copy link
Copy Markdown
Contributor Author

working on a rebase

@andrewd-zededa
andrewd-zededa force-pushed the eve-k-purge-cleanup-part2 branch from 679921b to cfb5a11 Compare October 27, 2026 16:24
@github-actions
github-actions Bot requested a review from rucoder October 27, 2026 16:25
@andrewd-zededa

Copy link
Copy Markdown
Contributor Author

Expanding the fix to gate on cluster mode IsReplicated and dnid/backup dnid handling.

@andrewd-zededa
andrewd-zededa force-pushed the eve-k-purge-cleanup-part2 branch from cfb5a11 to 806e550 Compare October 27, 2026 22:56
@andrewd-zededa

Copy link
Copy Markdown
Contributor Author

@andrewd-zededa Heads-up on a collision: #6478 adds RunKubectl and EVEKubeAppNamespace to evetest/edgedevice.go as well. Same method on *EdgeDevice, same const in package evetest, so whichever of us merges second is a redeclaration compile error rather than a textual conflict. We also both touch tests/apps/appworkload_helpers_test.go, tests/apps/purge_helpers_test.go and tests/cluster/testsuite_test.go.

Neither version is a superset of the other, so this needs a decision rather than a drop:

  • Yours bakes -n eve-kube-app into RunKubectl and takes the timeout from kubectlCommandTimeout. Mine passes the args through verbatim with a caller-supplied timeout, because two of its call sites need something else: -n longhorn-system delete pod -l app=csi-provisioner for the Longhorn CSI workaround, and tiebreaker_test.go's cluster-scoped get nodes … on its 2-minute budget.
  • Yours returns stdout and stderr separately and exports KubeItemList + KubectlListItems, which is the better half on decoding — one type reused across vmirs and pvc. Mine folds stderr into the error and leaves the list shapes local, so it has nothing to offer there. What it does add is ListAppVMIRS in the framework, where yours keeps listAppVMIRS unexported in tests/apps; that is what let the three-node purge test move into tests/cluster beside the others.

The union would be roughly RunKubectl(namespace, args string, timeout time.Duration) (stdout, stderr string, err error), with KubectlListItems and ListAppVMIRS layered on it. Events are the one thing neither covers — reason/message/involvedObject are not in KubeItemList — so the Longhorn workaround keeps decoding those itself either way.

Either order works from here: you fold it into #6406 and I rebase #6478 onto it, or I land the framework commit from #6478 ("evetest: reach kubectl through the framework", which is a separate commit for exactly this reason) and you drop yours. Do you have a preference? Worth settling soon — #6478 only compiles today because this one has not merged.

@eriknordmark I rebased on your changes, this branch should be ready soon

@andrewd-zededa
andrewd-zededa force-pushed the eve-k-purge-cleanup-part2 branch from 806e550 to f146368 Compare October 28, 2026 04:18
@andrewd-zededa
andrewd-zededa force-pushed the eve-k-purge-cleanup-part2 branch from f146368 to 620e434 Compare October 28, 2026 14:57
@andrewd-zededa
andrewd-zededa marked this pull request as ready for review October 28, 2026 18:45

@eriknordmark eriknordmark left a comment

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.

LGTM

andrewd-zededa and others added 3 commits October 28, 2026 12:58
sweepStaleGenerations deletes a stale purge generation's VMIRS and pod,
but not its PVC. When the purge lands while the node is down, volumemgr
never creates a VolumeStatus for the old generation, so nothing deletes
that PVC.

Add gcPVCs to volumemgr's GC tick. The PVC list is cluster-wide, but a
controller need not send every volume to every node, so a PVC this node
has no record of may be live elsewhere. gcPVCs deletes a PVC only when
this node's config holds the same volume at a newer generation, no
VolumeConfig or VolumeStatus here names the PVC's own generation, and
this node owns the volume or is its backup DNID.

gcPVCs runs on volumemgr's main loop, so GetPVCList takes a deadline
from its caller, and gcPVCs uses a short one since the next tick
retries. DeletePVC gets the kubeAPITimeout the other kubeapi calls use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Andrew Durbin <andrewd@zededa.com>
EdgeDevice gains KubectlListNames, built on RunKubectl, so a test can
list PVCs and other objects in the EVE app namespace. tests/apps kept a
local copy of this helper; the cluster tests now need it too.

EdgeClusterConfig gains AddBlankVolume. It gives every selected node the
same standalone volume. It can leave nodes out, because a controller
need not send a volume to every node of a cluster, and it can start the
volume at a later generation or under a UUID the test chose.

EdgeCluster gains WaitForFreshNodesReady. After a power-off, the last
cluster report still shows the node Ready, so WaitUntilNodesAreReady
returns before it has booted. The fresh variant counts only reports
that arrive after the call, and replaces the upgrade test's own copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Andrew Durbin <andrewd@zededa.com>
assertNoOrphanedPVCs asked only that each PVC present was expected, and
listPVCNames returned an empty list on any kubectl error, so the check
passed while k3s was down. listPVCNames now fails on a kubectl error, and
the check also requires each created volume to still have its PVC.
TestVMAppPurgeAfterPowerCycle runs it again, with timer.gc.vdisk at its
60s floor and a shorter timeout to match.

TestClusterPVCGCDeletesOnlyOrphans runs on three nodes. A standalone
persistent volume goes to two of them only. An orphan PVC is created
under a volume no node has yet, so it stays put, and the volume is then
sent at generation 1. The designated node deletes the orphan, and later
the backup DNID deletes the app volume's superseded PVC while the
designated node is down. The persistent PVC survives on every node,
including the one with no config for it. A checkpoint marks each of
these states.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Andrew Durbin <andrewd@zededa.com>
@andrewd-zededa
andrewd-zededa force-pushed the eve-k-purge-cleanup-part2 branch from 620e434 to 696c3f2 Compare October 28, 2026 19:03
@andrewd-zededa

Copy link
Copy Markdown
Contributor Author

pushed for CI linting issues

@github-actions
github-actions Bot requested a review from eriknordmark October 28, 2026 19:05
@github-actions

Copy link
Copy Markdown
Contributor

evetest: skipped suites/tests for this PR

This PR is scoped to eve-k volumemgr's PVC garbage collection (gcPVCs/pvcsToReap, GetPVCList/DeletePVC deadlines) plus the evetest cluster/purge/upgrade helpers added to exercise it. Based on that scope, the following are skipped for this run:

Unrelated whole suites (different subsystem entirely):

  • TestApplicationConnectivitySuite, TestBootstrapSuite, TestDeviceConnectivitySuite — networking/connectivity, not volumes.
  • TestControllerFaultsSuite — controller error reporting.
  • TestDatastoreSuite — image download backends.
  • TestDiagSuite — diag output.
  • TestHardwareSuite — USB hotplug.
  • TestLPSSuite — local profile server.
  • TestPcibackErrorSuite — PCI passthrough error reporting.
  • TestPortScanSuite — external security port scan.
  • TestSecuritySuite — vTPM/vault/certs.
  • TestStorageSuite — KVM qcow2/zvol storage, not kube PVCs.
  • TestTelemetrySuite — device info/metrics/logs reporting.
  • TestKonvertSuite — KVM-to-K migration; touches PVCs only via CDI image upload, never a purge/stale generation, so gcPVCs's new logic is never exercised.
  • TestKubeRegistrationSuite — cluster/node registration, no purge or PVC-generation handling.

Redundant/unrelated individual tests within otherwise-related suites (kept representative coverage instead):

  • In TestAppsSuite: TestPurgeNeverActivatedApp, TestVNC, TestAppInstanceMetadata, TestAppUserData, TestAppLogs, TestCgroupTree, TestMemoryPressureEvents, TestAppRestart, TestAppTeardownWithRemovedAdapter, TestDeviceShutdownAndRecovery, TestHaltAfterImmediateDeactivate, TestHaltUnresponsiveGuest, TestWorkerPoolSaturation, TestLotsOfApps, TestLayerDownloadErrorsBounded, TestVGAPassthroughNoHostAccess, TestContainerdCPUs — app lifecycle/logging/metadata/cgroup concerns, unrelated to volume-generation reclaim. TestVMAppPurgeReplacesVMIRS and TestVMAppPurgeAfterPowerCycle (which this PR modifies directly) are kept.
  • In TestNodeClusterSuite: TestSingleNodeCluster, TestNativeKubeAppNetworking, TestThreeNodesCluster, TestThreeNodesPortScan, TestMgmtProxy, TestTieBreakerCluster, TestClusterToSingleConversion, TestClusterVMApp — only reference PVCs in passing (provisioning/storage-class), never purge a generation. TestAppInstancePurge is kept.
  • In TestNodeClusterResilienceSuite: TestVMIRSStrandedReplicasRecovery (VMIRS replica self-healing, unchanged code), TestDNIDandBackupDNID (designated/backup-node assignment, unchanged, and its power-off scenario is already covered by the new test below), TestClusterPVCRedownload (avoiding redundant content-tree downloads, a different code path). TestClusterPVCGCDeletesOnlyOrphans (the new dedicated test for this PR) and TestVMAppPurgeDuringFailover (purge issued while a node is down — the exact bug scenario) are kept.
  • In TestUpgradeSuite: TestEVEUpgrade (and its KVM/Kubevirt variants) — plain version upgrades with no purge/stale-generation scenario. TestThreeNodesUpgrade is kept since it exercises this PR's EdgeCluster.WaitForFreshNodesReady refactor.

An engineer can comment /evetest all to force the full suite to run instead, or /evetest <name> <name> ... to run only specific tests/suites.

@rene
rene merged commit 44fb8a3 into lf-edge:master Oct 30, 2026
72 of 76 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

next-17.0.x-rc PR must be present in the next 17.0.x-lts release stable Should be backported to stable release(s)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants