Repository navigation
[17.0-stable] Ask pubsub whether the metrics fit - #6476
Merged
eriknordmark merged 1 commit intoSep 8, 2026
Merged
eriknordmark merged 1 commit into
eriknordmark merged 1 commit into
Conversation
The URLCounters cap counts entries, but what it defends is the encoded size of the published map, and the length of the URL keys dominates that. A run of long URLs -- a registry blob URL, or a datastore URL carrying a query string -- puts the map over the limit at an entry count the cap still allows, and pubsub answers an oversized value with a fatal rather than an error, taking down an agent that was only reporting on itself. Ask before publishing, and give up the least recently used entries, counting each as redacted, until what is left fits. If even an empty set of URL counters does not fit, report that and skip the publication instead of letting it be fatal. Signed-off-by: eriknordmark <erik@zededa.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
6 of 8 tasks
milan-zededa
approved these changes
Sep 7, 2026
eriknordmark
marked this pull request as ready for review
September 7, 2026 22:04
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 17.0-stable #6476 +/- ##
===============================================
+ Coverage 21.36% 21.76% +0.40%
===============================================
Files 500 510 +10
Lines 92628 94345 +1717
===============================================
+ Hits 19786 20538 +752
- Misses 71197 71979 +782
- Partials 1645 1828 +183 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Backport of #6434 to
17.0-stable, of the single commitb5da0e0, as requested there: a customer on
this branch is hitting the pubsub fatal that large URL metrics cause.
makeRoomForNewURLcaps how manyURLCountersentries are kept, but whatpubsub limits is the encoded size of the published map, which the length of the
URL keys dominates. A run of long URLs -- a registry blob URL, or a datastore
URL carrying a query string -- puts the map over the limit at an entry count the
cap still allows, and pubsub answers an oversized value with a fatal rather than
an error, taking down an agent that was only reporting on itself.
Publishnowasks whether the value fits, gives up the least recently used entries until what
is left does, and reports rather than publishes if even an empty set does not.
The commit sits on top of the rest of #6434, which is not being backported, so
it was first rebased onto master and then cherry-picked here. Dropped in the
rebase: the
net/httpimport and the twoRecordAnswerhunks git offeredalongside, which belong to an earlier commit of #6434. Nothing the fix does was
changed, and the pick onto this branch was clean -- both touched files are
identical between master and
17.0-stable.PR dependencies
Builds on the
URLCountersentry cap from #6409, already merged here.#6434 has not merged, so the commit carries no
(cherry picked from commit ...)trailer -- there is no master SHA to reference yet, and the fork-branchSHA is not the one that will land. This PR stays in draft until then; the commit
will be re-created with
git cherry-pick -x <landed sha>and force-pushed once#6434 merges.
How to test and validate this PR
Covered by automated unit tests,
make -C pkg/pillar test: three new cases incontrollerconn-- a map that fits publishes untouched, one that does not istrimmed least recently used first until it does, and one that cannot fit at all
is reported rather than published.
fakePublicationapplies the limit the waythe socket driver does, base64-encoding the value before measuring it, so the
tests exercise the real framing rather than the raw JSON length.
Validated against un-fixed code on this branch: removing the
CheckMaxSizeloop from
PublishmakesTestAgentMetricsPublishEvictsUntilItFitsandTestAgentMetricsPublishGivesUpWhenNothingLeftToDropfail on their assertions,and both pass again once restored.
Per-branch verification:
gofmt -l controllerconn/,go build ./...,go vet ./controllerconn/ ./types/andgo test ./controllerconn/ ./types/allexit 0.
Changelog notes
An agent reporting many distinct URLs -- most often the downloader, pulling
image blobs -- no longer dies when its metrics grow past the size a pubsub
message can carry. The oldest per-URL entries are given up instead, and counted
as redacted.
PR Backports
URLCounterscap this builds on is not present there.URLCounterscap this builds on is not present there,and the code still lives in the pre-rename
pkg/pillar/zedcloudpackage.Checklist
interface changes.
architecture independent.
For backport PRs: