Skip to content

[13.4-stable] zedmanager: drive purge state machine to completion in doUpdate - #6900

Closed
milan-zededa wants to merge 1 commit into
lf-edge:13.4-stablefrom
milan-zededa:13.4-backport-5618-purge-doupdate
Closed

milan-zededa wants to merge 1 commit into
lf-edge:13.4-stablefrom
milan-zededa:13.4-backport-5618-purge-doupdate

Conversation

@milan-zededa

@milan-zededa milan-zededa commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Description

Backport of #5618 to 13.4-stable.

Full backport, clean cherry-pick with -x from d66fc446a1, no conflicts.

The PR has no evetest test of its own. It is the first of the purge fixes that TestPurgeNeverActivatedApp (#6901) runs on top of.

PR dependencies

None.

How to test and validate this PR

Run the purge tests of the apps suite (added to 13.4-stable by #6899), together with the backport of #5742 (#6901):

EVETEST_EVE_VERSION=<13.4-stable build with this PR> make evetest NAME=TestPurgeNeverActivatedApp

Changelog notes

Fixed an application purge that got stuck in HALTING when nothing was running to tear down.

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

For backport PRs (remove it if it's not a backport):

  • I've added a reference link to the original PR
  • PR's title follows the template

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.

Fix app instance getting permanently stuck in HALTING state with
PurgeInprogress=BringDown during a purge operation.

The purge state machine has the following transitions:

  DownloadAndVerify → BringDown → RecreateVolumes → BringUp

The BringDown → RecreateVolumes transition was only implemented in
removeAIStatus(), which is called from updateAIStatusUUID() when it
observes PurgeInprogress==BringDown. However, doUpdate() also drives
the DownloadAndVerify → BringDown transition and calls doRemove()
inline. When doRemove() completes synchronously (no domain or network
to tear down), doUpdate() falls through with PurgeInprogress still set
to BringDown. If no subsequent event triggers updateAIStatusUUID()
(e.g. no DomainStatus, AppNetworkStatus, or VolumeRefStatus changes),
removeAIStatus() is never called and the state machine stalls.

This happens in practice when:
1. A purge counter mismatch is detected on reboot
2. handleCreateAppInstanceStatus calls doUpdate directly
3. The low-priority app boot path (checkLowPriorityApps) calls doUpdate
4. doRemove completes instantly because nothing is running
5. Nothing triggers another status re-evaluation

After doRemove() completes, drive the state machine forward to
RecreateVolumes and call purgeCmdDone() to persist the purge counter.
This ensures the purge completes regardless of which code path invoked
doUpdate(), and prevents the purge from being re-detected on subsequent
reboots.

Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
(cherry picked from commit d66fc44)
@codecov

codecov Bot commented Oct 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 32.66%. Comparing base (8077a3d) to head (ae2e2e8).
⚠️ Report is 319 commits behind head on 13.4-stable.

Additional details and impacted files
@@               Coverage Diff               @@
##           13.4-stable    #6900      +/-   ##
===============================================
+ Coverage        24.78%   32.66%   +7.88%     
===============================================
  Files                8        9       +1     
  Lines             1138     1090      -48     
===============================================
+ Hits               282      356      +74     
+ Misses             788      654     -134     
- Partials            68       80      +12     

☔ 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

Copy link
Copy Markdown
Contributor

The Eden User Apps suite fails here at purge_not_activated_test.txt:60 (job). This PR backports only #5618; the test also needs #5742, which fixes purging an app that was never activated.

#6901 carries an identical patch of this commit plus the #5742 backport, and passes User Apps. These must merge as a pair: merge #6901, which makes this PR redundant, rather than this one on its own.

@milan-zededa

Copy link
Copy Markdown
Contributor Author

Closing: #6901 was stacked on this PR, carried this commit (the backport of #5618) and is already merged, so 13.4-stable has this change (ddfc3b6411).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants