Read one line of VERSION_CODENAME from os-release - #240
Open
jetm wants to merge 1 commit into
Open
Conversation
Every dnf call in the SDK fails when AVOCADO_SDK_REPO_RELEASE is unset, which is the default path. The fallback reads the codename with an unanchored grep, and os-release is a key=value file rather than a map: nothing stops a key repeating, and both published SDK images repeat this one. Measured 2026-09-04 - avocadolinux/sdk:2024-edge and :2026-edge each carry two identical VERSION_CODENAME lines. The value is then two lines, so `dnf --releasever=$REPO_RELEASE` hands dnf the second line where it expects a subcommand and it exits with "No such command: 2024/edge". What made this expensive to find is where it surfaces. The kernel resolver routes both of its repoqueries through `2>/dev/null || true`, so a dnf that never ran looks exactly like a dnf that ran and matched nothing. The operator sees "no kernel versions found in the repository to choose from" against a repository that has them, with the real error discarded two layers down. Cost was most of an evening on a feed that was correct all along. Bounding the read to the first match keeps the reader correct against any os-release, rather than against the two images whose contents happen to be known today. The executing test lifts the pipeline out of this file rather than restating it, so it exercises what the script emits; an inlined copy would pass against a fix that never shipped. The second test counts the emission sites, because the two copies are edited independently and reverting either one alone is a regression the executing test cannot see - it reads whichever site it finds first. That test scopes itself to the source above the test module, since its own literals otherwise inflate both counts. Not fixed here: the images should stop shipping the key twice. This makes the reader correct regardless, which is the layer that can be fixed from this repo.
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.
Problem
Every dnf call inside the SDK fails when
AVOCADO_SDK_REPO_RELEASEis unset,which is the default path. The generated entrypoint reads the release codename
from
/etc/os-releasewith an unanchoredgrep, and os-release is a key=valuefile rather than a map: nothing stops a key repeating, and both published SDK
images repeat this one. Measured 2026-09-04,
avocadolinux/sdk:2024-edgeand:2026-edgeeach carry two identicalVERSION_CODENAMElines.REPO_RELEASEis then two lines, sodnf --releasever=$REPO_RELEASEhands dnfthe second line where it expects a subcommand and it exits with
No such command: 2024/edge.Solution
Bound the read to the first match, so the reader is correct against any
os-release rather than against the two images whose contents happen to be known
today.
Key changes
head -1.Reviewer notes
What made this expensive to find is where it surfaces, and that part is not
fixed here. The kernel resolver routes both of its repoqueries through
2>/dev/null || true, so a dnf that never ran looks exactly like a dnf that ranand matched nothing. The operator sees
no kernel versions found in the repository to choose fromagainst a repositorythat has them, with the real error discarded two layers down. That swallowing is
worth a separate look; this change only stops one cause of it.
Also not fixed here: the images should stop shipping the key twice. This
makes the reader correct regardless, which is the layer reachable from this repo.
Feedback I am after: whether
head -1is the right anchor versus taking thelast match, and whether the site-counting test earns its keep or is too clever.
I chose first-match because a repeated key with differing values is already
broken and the first is what a shell
sourceof os-release would leave set.