Skip to content

eve-k: let a healthy peer act for a downed node's designated app (backup DNID) - #6505

Merged
rene merged 23 commits into
lf-edge:masterfrom
andrewd-zededa:eve-k-backup-dnid
Sep 23, 2026
Merged

rene merged 23 commits into
lf-edge:masterfrom
andrewd-zededa:eve-k-backup-dnid

Conversation

@andrewd-zededa

@andrewd-zededa andrewd-zededa commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

EVE-K restricts each cluster app instance's operations -- activate,
deactivate, purge, delete -- to its Designated Node ID (DNID): only that
node's own zedmanager is allowed to act on the app's config. That's a
pillar-level restriction, not a Kubernetes scheduling one -- a
Preferred-affinity workload could already be scheduled onto any node in
the cluster. So until now, if the DNID node went down, nothing could drive
that app's lifecycle at all, even though the workload itself was free to
run elsewhere.

This PR lets a healthy peer act on a Preferred-affinity app in its
designated node's place once that node has been unhealthy for longer than
cluster.dnid.backupnode.threshold (default 10 minutes, configurable). One
node is elected via a new eve-app-op Kubernetes lease to avoid two peers
racing to activate the same app; kubeapi.IsCurrentlyBackupDNID combines
that election with a live health read of the designated node before any
node acts. The app moves back to its real designated node automatically once
that node recovers (see "How to test" below for the config this requires).

Required-affinity apps are excluded throughout: Kubernetes itself refuses
to schedule one anywhere but its designated node, so nothing here changes
for them.

Along the way, two related gaps in existing behavior are fixed, since the
new backup-DNID path exercises them directly:

  • hypervisor.Delete skipped a domain that Kubernetes had already
    rescheduled elsewhere without checking whether that other node was
    actually healthy, which could wedge a delete against a node that was
    itself down.
  • A new VMI or pod's affinity was always stamped with the creating node's
    own name, never the app's actual designated node. During a backup
    activation that meant the live object's affinity never named the true
    home to begin with, so failback silently never reached the running
    workload even after zedkube's reconciler corrected the ReplicaSet
    template. Affinity is now resolved from the app's real designated node
    (falling back to the local node if that can't be resolved), so the
    descheduler's existing template-vs-affinity mismatch detection can
    actually find and move it back.

Known gap, deliberately not fixed here: a Required-affinity app
deleted while its designated node has never been reachable (so no node ever
holds the in-memory domain state needed to delete its Kubernetes
ReplicaSet) still leaks that ReplicaSet, endlessly retried by Kubernetes'
own controller. TestDNIDandBackupDNID uses Preferred affinity for the
app it deletes specifically to avoid this; it's tracked separately, not
exercised by this PR.

PR dependencies

A number of PRs have been identified through the work towards getting this new test passing:

How to test and validate this PR

Covered by TestDNIDandBackupDNID, an evetest test requiring a three-node
cluster environment and internet access (the apps boot a real Alpine image
from dl-cdn.alpinelinux.org). The test:

  1. Boots two Preferred-affinity apps (vm1, vm2) and one more (vm3) on
    separate designated nodes, and confirms kubernetes.vmi.deschedule.events
    accepts boot (required for failback -- see below).
  2. Powers off vm2's designated node, then activates vm2 from a peer and
    confirms it actually runs there, not merely reports configured there.
  3. Deactivates, reactivates, and purges vm2 again while its designated node
    is still down, confirming each operation lands on the backup node.
  4. Deletes vm3 (Preferred affinity, already running on a backup node) and
    confirms both its app info and volume info converge to INVALID.
  5. Powers the original designated node back on and confirms vm2 fails back
    onto it automatically.

Run it with:

make evetest NAME=TestDNIDandBackupDNID
EVETEST_LOG_LEVEL=debug make evetest NAME=TestDNIDandBackupDNID
EVETEST_PAUSE_ON_FAILURE=true make evetest NAME=TestDNIDandBackupDNID
make evetest NAME=TestNodeClusterSuite   # runs last in this suite

To step through and inspect each stage individually rather than running to
completion or failure, pause at every checkpoint in turn:

EVETEST_PAUSE_ON_CHECKPOINT=setup-done EVETEST_PAUSE_ON_FAILURE=true \
    make evetest NAME=TestDNIDandBackupDNID

then, per checkpoint (see the test source for the full ordered list):

evetest continue --until <next-checkpoint-name>

Config prerequisites the test sets itself, but worth calling out for
manual validation too:

  • kubernetes.vmi.deschedule.events=boot -- without it, failback never
    happens; an app that moved to another node just keeps running there.
  • cluster.dnid.backupnode.threshold -- defaults to 600s (10 minutes,
    min 60s, max 86400s); lower it for a faster manual test cycle. The
    effective delay adds the Kubernetes node-monitor grace period on top and
    is floored at the eve-app-op lease duration regardless.

Changelog notes

EVE-K clusters: when an app instance's designated node has been unhealthy
for longer than cluster.dnid.backupnode.threshold (default 10 minutes),
another cluster node can now activate, deactivate, purge, or delete that
app on its behalf, and the app automatically moves back once its
designated node recovers (requires kubernetes.vmi.deschedule.events to
include boot). Applies only to apps configured with Preferred node
affinity; apps configured with Required affinity are unaffected and
continue to wait for their designated node to come back.

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.

@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 Sep 10, 2026
@codecov

codecov Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 35.58106% with 449 lines in your changes missing coverage. Please review.
✅ Project coverage is 26.82%. Comparing base (433f1e7) to head (466cb1d).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
pkg/pillar/cmd/zedkube/leaderelect.go 55.11% 56 Missing and 1 partial ⚠️
pkg/pillar/cmd/zedmanager/dnidbackup.go 31.32% 57 Missing ⚠️
pkg/pillar/cmd/zedmanager/zedmanager.go 0.00% 54 Missing ⚠️
pkg/pillar/kubeapi/backupdnid.go 30.66% 52 Missing ⚠️
pkg/pillar/cmd/volumemgr/dnidbackup.go 52.80% 39 Missing and 3 partials ⚠️
pkg/pillar/cmd/volumemgr/volumemgr.go 0.00% 42 Missing ⚠️
pkg/pillar/hypervisor/kubevirt.go 56.66% 36 Missing and 3 partials ⚠️
pkg/pillar/cmd/zedkube/zedkube.go 0.00% 34 Missing ⚠️
pkg/pillar/cmd/zedkube/kubestatscollect.go 0.00% 23 Missing ⚠️
pkg/pillar/cmd/domainmgr/domainmgr.go 14.28% 17 Missing and 1 partial ⚠️
... and 12 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6505      +/-   ##
==========================================
+ Coverage   26.36%   26.82%   +0.45%     
==========================================
  Files         516      529      +13     
  Lines       95230    97480    +2250     
==========================================
+ Hits        25108    26145    +1037     
- Misses      68168    69177    +1009     
- Partials     1954     2158     +204     

☔ 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-backup-dnid branch 5 times, most recently from d4c2531 to 398f3f1 Compare September 15, 2026 14:30
@andrewd-zededa andrewd-zededa changed the title evetest: add TestDNIDandBackupDNID for DNID backup takeover eve-k: let a healthy peer act for a downed node's designated app (backup DNID) Sep 15, 2026
@andrewd-zededa
andrewd-zededa marked this pull request as ready for review September 15, 2026 21:17
}
if !onMe && !scheduledOnNone {
// Not scheduled on me, but is scheduled elsewhere.
if !onMe && !scheduledOnNone && elsewhereReady {

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.

this 'elsewhereReady' can be false due to temp glitch accessing the apiserver, then it should skip this block and move to delete?

// does not silently drop the app's last state (e.g. HALTED) on the
// floor once Kubernetes clears ScheduledOnThisNode.
if config := lookupAppInstanceConfig(ctx, key, true); config != nil {
canReport = isCurrentlyBackupDNIDForApp(ctx, *config)

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.

and for each app status, we are going to eventually calling api-server to access? seems expensive

// giving up a lease during a baseos update is not what a temporary
// failure asks for.
log.Noticef("handleControllerStatusChange: temporary failure, " +
"elections left running")

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.

do we need to stop the election timer in this case?

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.

Good catch, yes. TemporaryFail is only set while the new image is on trial
(in_progress partition, post-reboot), and zedagent arms ConfigGetFail before
every request -- so Fail -> TemporaryFail is the normal sequence there, and
the stop armed by that Fail survives this branch and fires ~90s later,
dropping the lease mid-validation. Will add cancelElectionStop() here, plus a
regression test; the existing one only covers Success -> TemporaryFail, where
no timer was armed.

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 in commit 017a0d5

@naiming-zededa

Copy link
Copy Markdown
Contributor

I think we normally have zedkube to monitor all the cluster, volumemgr and domainmgr do the creating objects in the cluster. This PR also does 'zedmanager' to query the cluster for if the DNID node is up or down, and some other api-server access.
I would think a simpler way is using the 'zedkube', since it is already looping through the cluster every few minutes.
in the type 'ENClusterAppStatus' add a new item 'DNIDNodeNotReadyTimeSince' timestamp, if the app's DNID is down/not-ready, and if this node is the elected-leader to handle the non-DNID thing, publish this timestamp. 'zedmanager' already subscribe to this, and it can decide if it is over certain minutes of this 'not-ready', it can go ahead to trigger the action, without accessing the api-server itself.

@andrewd-zededa

Copy link
Copy Markdown
Contributor Author

Found a missing step in the test for proper purge coverage, fixing now. Will address review comments soon

andrewd-zededa and others added 8 commits September 22, 2026 16:54
Delete's "not scheduled on me, but is scheduled elsewhere" skip assumed
elsewhere always means a live pillar instance will handle its own
teardown. That breaks deleting a Required-affinity app while its
designated node is down: the VMIRS/pod object persists in Kubernetes
(a dead node's bindings don't vanish), so scheduledOnNone reads false,
the skip fires, and nothing ever issues the real delete -- the object
sits there, permanently retried by Kubernetes' own ReplicaSet
controller, since the designated node, once it reboots, has no config
left telling it the app was deleted either.

Add elsewhereReady, threaded through scheduledOnMe and its VMI/pod
implementations, backed by a new kubeapi.IsNodeReady (reusing
backupdnid.go's existing node-Get and Ready-condition helpers). Delete
now only defers to elsewhere when that node is actually able to act;
otherwise it does the delete itself. Info() and Stop() discard the new
value -- their existing scheduledOnNone-based behavior is unchanged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Andrew Durbin <andrewd@zededa.com>
Only rewrite a VMIRS's affinity back to this (DNID) node once the node
currently named in it is confirmed gone from the cluster, not merely
unreachable. A temporarily-down peer keeps its Node object, so this no
longer fires the instant it reconnects, only once it's actually been
replaced.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Andrew Durbin <andrewd@zededa.com>
Creation always baked the creating node's own name into a new VMI or
pod's affinity, never the app's actual designated node. During a
backup-DNID failover the backup node runs the creation locally, so it
stamped its own name -- meaning the live object's affinity never named
the true home to begin with, no matter what zedkube's reconciler later
did to the VMIRS template.

Resolve AppInstanceConfig's DesignatedNodeUUID (now carried through
DomainConfig) to its current node name and use that for the affinity,
falling back to the local node if there's no UUID to resolve or the
lookup fails.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Andrew Durbin <andrewd@zededa.com>
A replicated volume's own doUpdateVol short-circuit
(status.IsReplicated -> CREATED_VOLUME, no real creation work) fires
for every volume on a node that isn't its app's designated node --
confirmed live: a purge on a backup node left its new volume's PVC
never even requested, so the VMI sat Pending on FailedPvcNotFound
forever. The volume-generation policy driving the purge made no
difference; the check is a static designated-node identity compare,
unrelated to the volume's UUID or replica history.

Bypass it once this node is confirmed eligible to act as backup DNID
for that volume (holds the eve-app-op lease, the designated node has
been unhealthy past the configured threshold, and the app is not
Required-affinity) -- the same decision zedmanager already makes for
app activation, reused here via kubeapi.IsCurrentlyBackupDNID.

Needs its own DesignatedNodeUUID/AffinityType on VolumeConfig
(cross-referenced from the owning app's VolumeRefList in
parseVolumeConfig, mirroring the existing IsNativeContainer walk),
since IsReplicated only ever encoded "not me", never "who". And needs
its own re-drive: backup DNID changes nothing in the volume's own
config, so nothing else notices a volume newly eligible for takeover --
added to volumemgr's existing gc-ticker batch of re-drive passes,
alongside a new eve-app-op lease subscription mirroring zedmanager's.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Andrew Durbin <andrewd@zededa.com>
An image-backed volume's content tree hits the same designated-node
identity gate (IsLocal) as the volume itself and parks at LOADED with
zero blobs, so doUpdateVol waits forever on casClient.GetImageHash --
keyed by the content tree's own UUID, which nothing dedupes across
apps referencing identical content, so a sibling's download never
helps.

doUpdateContentTree never revisits an already-LOADED status, so this
re-drives via the same delete-and-recreate path
handleContentTreeModify already uses for a real DNID reassignment,
passing the recreate a locally-overridden copy (IsLocal forced true).

ContentTreeConfig gets its own DesignatedNodeUUID (carried directly on
the wire, unlike volumes). Affinity is read off whichever volume(s)
reference the content tree instead, since it has none of its own.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Andrew Durbin <andrewd@zededa.com>
…ache

isCurrentlyBackupDNIDWithClient did a live Nodes().Get() on every call,
once per app in zedmanager and once per volume and content tree in
volumemgr on every relevant pass -- flagged as expensive in review.

zedkube now republishes every node's Ready status and its last
transition time, keyed by device UUID, on every node's own
appStatusTimer tick rather than only on the stats-lease holder.
kubeapi.IsCurrentlyBackupDNID takes a NodeHealthLookup function instead
of building a client itself; zedmanager and volumemgr each subscribe to
the new publication and implement the lookup against their own local
cache. The eligibility logic itself is unchanged: not-found, a
zero/future transition time, and the ready/threshold checks all carry
over exactly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Andrew Durbin <andrewd@zededa.com>
doInstall deliberately skips its "volumes have reached CREATED_VOLUME"
gate while a purge is in BringDown, because that phase is tearing the
old domain down rather than standing a new one up. doUpdate then fell
through to doActivate anyway, bringing the app up on volumes that are
still being recreated -- a PVC binds and attaches from the moment it
exists, so a domain can boot on one with nothing written into it.

updateAIStatusUUID already routes BringDown to removeAIStatus and never
reaches doUpdate, but its other callers do. Give all of them the same
answer, in doUpdate itself.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Andrew Durbin <andrewd@zededa.com>
HandleCreated reported every CSI volume created as soon as the create
worker returned, and that report is what lets a volume reach
CREATED_VOLUME -- the state zedmanager gates app activation on. A PVC
binds and attaches whether or not CDI ever wrote the image into it, so a
volume whose upload did not finish would hand an app an empty disk to
boot from.

Confirm the upload actually completed for a volume that carries content,
and report an error rather than success when it did not, or when it
cannot be confirmed. A volume with no ReferenceName took the CreatePVC
path and has no content to confirm.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Andrew Durbin <andrewd@zededa.com>
@andrewd-zededa

Copy link
Copy Markdown
Contributor Author

rebased to resolve yetus, still need to review comments

andrewd-zededa and others added 5 commits September 22, 2026 18:41
WaitUntilAppIsRunning reflects only what the controller reports, and a
domain reports RUNNING once its process starts -- which says nothing
about whether the guest found anything to boot. TestDNIDandBackupDNID
stopped there, so an app brought up on a volume with no content in it
still read as a pass.

Start a BusyBox HTTP server in each VM through cloud-init and poll it
after every RUNNING wait, including both backup-DNID activations and the
failback. The local network instance is NAT'd, so each app forwards a
port on whichever node currently hosts it, and the check resolves that
node before polling.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Andrew Durbin <andrewd@zededa.com>
Alpine keeps the httpd applet in busybox-extras rather than core BusyBox,
so the readiness server never started: the guest booted and took a DHCP
lease, the port-forward DNAT was programmed correctly, and port 80 inside
the guest simply refused.

cloud-init is itself written in Python, so an image that honors this user
data at all carries a python3 to serve with, and nothing needs installing.
A server that fails to come up now says so on the console, which EVE
captures, instead of surfacing only as a readiness timeout.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Andrew Durbin <andrewd@zededa.com>
runcmd is per-instance: cloud-init records that it ran and skips it on
every later boot of the same instance. The readiness gate has to answer
on boots the test drives after the first one -- a deactivate/activate
pair and a failback both restart the same instance off the same disk, so
the server was simply absent there. Only a purge happened to work, and
only because it recreates the volume from the base image and wipes
cloud-init's state with it.

bootcmd runs on every boot. It runs before networking is configured, but
the server binds 0.0.0.0 and accepts once an address arrives.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Andrew Durbin <andrewd@zededa.com>
Every other point the test brings vm2 up gates on the guest answering,
but the purge did not -- it stopped at the controller reporting RUNNING.
That is the one step least able to afford it: the purge builds the volume
again from scratch, on a backup node, with the designated node down, so
it is the narrowest path there is for an app to come up on a disk whose
content never landed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Andrew Durbin <andrewd@zededa.com>
ConfigGetTemporaryFail is set only while the new image is on trial, after
the reboot into it, and this branch means to keep contending through that
window. It did not cancel a stop already armed, though: zedagent arms
ConfigGetFail before every request, so Fail -> TemporaryFail is the
ordinary sequence there, and scheduleElectionStopAfter is a no-op while a
timer exists. The armed stop fired ninety seconds in and released the
lease mid-validation, the outcome the branch exists to prevent.

The existing test only covered Success -> TemporaryFail, where nothing was
armed, so the gap went unnoticed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Andrew Durbin <andrewd@zededa.com>
@andrewd-zededa

Copy link
Copy Markdown
Contributor Author
  • amended the evetest commit with a defer resp.Body.Close() to resolve the yetus issue.

  • and a fix in 017a0d5 for @naiming-zededa for "zedkube: cancel a pending election stop on a temporary failure"

@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

@rene
rene merged commit cbb17f4 into lf-edge:master Sep 23, 2026
49 of 54 checks passed
@andrewd-zededa

Copy link
Copy Markdown
Contributor Author

Looks like a few dependent PRs are needed to get this back ported to 17.0-stable.
#6096
#6138
#6173
#6271

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.

5 participants