Skip to content

[17.0-stable] pillar: report nested-app runtime status errors - #7167

Open
andrewd-zededa wants to merge 2 commits into
lf-edge:17.0-stablefrom
andrewd-zededa:pr6890-17.0-stable
Open

andrewd-zededa wants to merge 2 commits into
lf-edge:17.0-stablefrom
andrewd-zededa:pr6890-17.0-stable

Conversation

@andrewd-zededa

Copy link
Copy Markdown
Contributor

Description

Backport of #6890

Report errors from a nested-app runtime (for example, a failure applying
cloud-init config) as app errors, next to the existing lifecycle error.

  • zedrouter polls the runtime's GET /api/v1/runtime/status alongside the
    existing nested-app metrics, and publishes the result as a new
    AppRuntimeStatus topic keyed by the app instance UUID. The topic is
    unpublished once the runtime is no longer polled (halt, re-address or
    delete). A runtime without this endpoint answers 404, which is logged at
    trace level only.
  • zedmanager copies it into a new AppInstanceStatus.RuntimeErr field, kept
    apart from the lifecycle error so neither replaces the other.
  • zedagent reports RuntimeErr as an additional AppErr entry with its own
    severity. LPS reports it when there is no lifecycle error, and diag prints
    it.

The runtime's errors are guest-controlled, and publishing an oversized pubsub
message is fatal, so the conversion keeps at most 4 entries of 160 bytes each,
highest severity first, and notes how many were omitted.

Both commits are cherry-picked with -x and applied unchanged.

PR dependencies

The MemoryDriver change notifications that TestSyncRuntimeErr waits on
(#5348) predate this branch, so unlike the 16.0-stable backport (#7118) no
other backport is needed.

How to test and validate this PR

Unit tests (automated):

make -C pkg/pillar TESTPKGS='./cmd/zedrouter/ ./cmd/zedmanager/ ./cmd/zedagent/ ./types/' \
  TESTRUN="'TestRuntimeStatus|TestFetchHTTPData|TestSyncRuntimeErr|TestAppErrors|TestAppInstanceStatusTruncateErrors'" \
  test

Changelog notes

Errors reported by a nested-app runtime, such as cloud-init failures, are now
shown as app errors.

PR Backports

This is the backport

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.

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

🤖 Generated with Claude Code

andrewd-zededa and others added 2 commits November 19, 2026 16:40
zedrouter now fetches the runtime's status (e.g. cloud-init failures)
from GET /api/v1/runtime/status and publishes it as a new
AppRuntimeStatus topic, keyed by app instance UUID, unpublishing it
once the runtime is no longer polled. zedmanager copies it into a new
AppInstanceStatus.RuntimeErr field, kept apart from the lifecycle
error so neither replaces the other.

zedagent reports RuntimeErr as an additional AppErr entry with its own
severity, LPS reports it when there is no lifecycle error, and diag
prints it.

The runtime's errors are guest-controlled, and publishing an oversized
pubsub message is fatal, so the conversion keeps at most 4 entries of
160 bytes each, highest severity first, and notes how many were
omitted. ErrorTime is the latest timestamp the runtime reported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 15b08bb)
Signed-off-by: Andrew Durbin <andrewd@zededa.com>
Cover runtimeStatusToErrorDescription's entry and length limits,
severity ordering and normalization, deterministic output, and
timestamp selection, check that a hostile runtime cannot push the
published AppRuntimeStatus near the pubsub message limit, and check
that fetchHTTPData reports a 404 as an httpStatusError.

Check that zedmanager copies AppRuntimeStatus into RuntimeErr without
touching the lifecycle error, that TruncateErrors also bounds
RuntimeErr, and that zedagent reports both errors in AppErr without
empty entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit e93e312)
Signed-off-by: Andrew Durbin <andrewd@zededa.com>
@andrewd-zededa andrewd-zededa added the next-17.0.x-rc PR must be present in the next 17.0.x-lts release label Nov 19, 2026
@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 37.66234% with 96 lines in your changes missing coverage. Please review.
✅ Project coverage is 24.17%. Comparing base (dc1e7b5) to head (aa2db69).
⚠️ Report is 8 commits behind head on 17.0-stable.

Files with missing lines Patch % Lines
pkg/pillar/cmd/zedrouter/appcontainer.go 42.10% 44 Missing ⚠️
pkg/pillar/cmd/zedmanager/zedmanager.go 0.00% 21 Missing ⚠️
pkg/pillar/cmd/diag/diag.go 0.00% 9 Missing ⚠️
pkg/pillar/cmd/zedmanager/handlezedrouter.go 66.66% 9 Missing ⚠️
pkg/pillar/cmd/zedrouter/zedrouter.go 0.00% 7 Missing ⚠️
pkg/pillar/localcommand/appinfo.go 0.00% 2 Missing ⚠️
pkg/pillar/types/zedroutertypes.go 0.00% 2 Missing ⚠️
pkg/pillar/cmd/zedagent/handlemetrics.go 87.50% 1 Missing ⚠️
pkg/pillar/cmd/zedrouter/pubsubhandlers.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           17.0-stable    #7167      +/-   ##
===============================================
+ Coverage        23.53%   24.17%   +0.64%     
===============================================
  Files              517      527      +10     
  Lines            95838    97563    +1725     
===============================================
+ Hits             22556    23590    +1034     
- Misses           71370    72102     +732     
+ Partials          1912     1871      -41     

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

@rene

rene commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

@claude

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @rene's task in 2m 20s —— View job


Review: PR #7167 — backport of #6890 to 17.0-stable

  • Gather context (two cherry-picked commits + vendored dependency)
  • Review correctness, bugs, security, performance
  • Verify backport integrity against 17.0-stable

Verdict: clean backport, no blocking issues

Both commits (d3d95fe8, aa2db698) are -x cherry-picks and apply unchanged. I verified the parts of the backport that could have drifted from the master original:

  • Dependency satisfied. nestedappinstancemetrics.RuntimeStatus (and GetId/GetErr/GetSeverity/GetTimestamp/GetDescription) is present in vendored eve-api on this branch (via the merged [17.0-stable] vendor: bump eve-api for nested-app runtime status #7136 re-pin), so the new zedrouter code resolves.
  • Type contract intact. AppRuntimeStatus embeds ErrorAndTime→ErrorDescription, so rtStatus.SetErrorDescription(...) (zedrouter) and rs.ErrorDescription (zedmanager) line up. SetErrorDescription forces a non-zero ErrorTime whenever Error != "", so the !RuntimeErr.ErrorTime.IsZero() guard in appErrors is consistent with the Error != "" guard used elsewhere (publishAppInstanceStatus, diag). ToProto() returning nil on zero time makes the localcommand nil-check correct.
  • Size bounding is sound. Guest-controlled runtime errors are capped (≤4 entries × 160 bytes, highest-severity-first, drop-count noted) before publish, and TruncateErrors now also trims RuntimeErr — the new errorbound_test.go / appcontainer_test.go cases cover the hostile-runtime path.
  • min(...) builtin is fine (pillar is on go 1.25).

Non-blocking observation

z.pubAppRuntimeStatus is published from the collectAppContainerStats goroutine (getNestedAppRuntimeStatus) while unpublishAppRuntimeStatus is also called from the main event loop (checkAppContainerStatsCollecting, cleanupDeploymentNestedArtifacts). This cross-goroutine pub/unpublish on one publication mirrors the existing pubNestedAppRuntimeStorageMetric pattern in the same file, so it is not introduced by this change and not a backport concern — flagging only for awareness.

No inline comments — nothing in the diff warrants a change for the backport.
· branch pr6890-17.0-stable

@github-actions

Copy link
Copy Markdown
Contributor

Evetest: Claude chose to skip 18 test/suite name(s) as unrelated to or redundant for this PR. Which ones and why: run summary.

Comment /evetest all to run the full suite, or /evetest <name> <name> ... to run only specific tests/suites.

This branch has not been deployed

No deployments
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants