Repository navigation
fix(platform): keep the network out of package-manager reads - #549
Merged
Merged
Conversation
TestResolveWithConfidence_NativePackage hung twice in one day on the ubuntu leg, each time taking the whole package down with it: 119s, no --- FAIL: line, because the test binary's 2m deadline expired while the process sat inside apt-get update. A GitHub runner appears to ship with its apt lists cleaned -- inferred, not measured, from the fact that every workflow installing a deb must run apt-get update first, ours included. Whatever the cause, indexAgeOf stats nothing, returns the unknownIndexAge sentinel of a year, and the 24h staleness gate fires on every run. The refresh was not a stall; it was a cold, complete index fetch of every source the image carries. Two minutes for that is unremarkable. Only its position was wrong. Two fixes, both narrowing what a read is allowed to do. Confidence no longer consults an index. ResolveWithConfidence asked router.Available(purl) to choose between ConfidenceMedium and ConfidenceLow, which made a per-machine fact -- is there a package manager here -- get re-derived once per package, at a subprocess each. PackageManager gains Present(), an exec.LookPath over a new rawDriver.executable() that each of the eight leaves supplies. Note apt reports apt-get: that is what it shells out to and what Debian declares stable for scripts. The router reports any leaf present, since a host with flatpak but not apt can still install natively. The staleness gate now distinguishes absence from age. Install and Upgrade resolve a specific version, so a lagging index installs a superseded build or fetches one the mirror has withdrawn -- they keep the age gate. Available and Search name no version (tokenFor returns p.Name), so age costs them nothing: package names and descriptions barely churn. Absence costs them everything, and silently -- with no index Available reports false for every package, indistinguishable from "no such package". So queries refresh for absence only, where the alternative is a confident wrong answer rather than a slightly old one. The rule, now in one line: refresh when the index is absent, or when the operation is a mutator; never merely because it is old. Also removes VerifySyntheticPackage, which had no callers anywhere including tests, and with it one of the three sites that detect the host directly instead of asking the runtime environment for it. This was never test-only. lore search reaches searchNative, and compositeManager.Search fans out to every leaf rather than routing to one, so each refresher leaf gated its own refresh -- an interactive command blocking on a network fetch with nothing on screen. Refs #439.
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.
The bug
TestResolveWithConfidence_NativePackagehung twice in one day on ubuntu, each time killing its wholepackage's verdict:
No
--- FAIL:line, because the binary panicked rather than any test failing.It was sitting in
apt-get update. A GitHub runner appears to ship with its apt lists cleaned -- inferred fromthe fact that every workflow installing a deb must run
apt-get updatefirst, ours included; I have notconfirmed it on a runner. Either way
indexAgeOfstats nothing, returns theunknownIndexAgesentinel of ayear, and the 24h gate fires on every run. Not a stall -- a cold, complete fetch of every source the image
carries. Unremarkable in itself; wrong only in where it was triggered from.
Two fixes
1. Confidence no longer consults an index.
ResolveWithConfidenceusedrouter.Available(purl)to pickConfidenceMediumoverConfidenceLow-- askinga per-package question to answer a per-machine one, so the fact was re-derived once per package at a subprocess
each.
PackageManagergainsPresent(): anexec.LookPathover a newrawDriver.executable(), supplied byeach of the eight leaves.
aptreportsapt-get-- what it actually shells out to, and the interface Debian declares stable forscripts. The router reports any leaf present, since a host with flatpak but not apt can still install
natively.
2. The staleness gate distinguishes absence from age.
Install/UpgradeAvailable/SearchtokenForreturnsp.Name, no versionInstalled/VersionAge costs the queries nothing: names and descriptions barely churn. Absence costs them everything, and
silently -- with no index
Availablereportsfalsefor every package, which a caller cannot distinguishfrom "no such package".
Not test-only
lore searchreachessearchNative, andcompositeManager.Searchfans out to every leaf rather thanrouting to one -- so each refresher leaf gated its own refresh. An interactive command blocking on a network
fetch with nothing on screen.
Also
Removes
VerifySyntheticPackage-- no callers anywhere, tests included -- and with it one of the three sitesthat detect the host directly instead of asking the runtime environment. The two survivors are both
Registrymethods in
search.go, now tracked under #446.Verified
make check-- exit 0, zeroFAILlinespresent_test.go: driver resolves a present binary, rejects a missing one; router reports any-leaf-presentacross four cases
update_test.go: mutators still refresh on a stale index; queries no longer do; both refresh on a missing oneRefs #439rather thanFixes: that issue is the class, and its charter requires enumerating everynetwork-reaching test before a fix is designed. This is one instance, which was not on its list.