fix(os): keep the fullest OS version when merging analyzer results - #11039
Open
DmitriyLewen wants to merge 2 commits into
Open
fix(os): keep the fullest OS version when merging analyzer results#11039DmitriyLewen wants to merge 2 commits into
DmitriyLewen wants to merge 2 commits into
Conversation
knqyf263
reviewed
Aug 10, 2026
| if o.Name == "" { | ||
| // One of the sources may report a shortened version, e.g. 7 and 7.9.2009 for CentOS. | ||
| // We always take the fullest version. | ||
| if o.Name == "" || (o.Family == newOS.Family && strings.HasPrefix(newOS.Name, o.Name+".")) { |
Collaborator
There was a problem hiding this comment.
Should we bump the relevant analyzer version so that old cached OS results are not reused?
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
/etc/os-releaseand the distro-specific release file can describe the same OS with different granularity.On CentOS 7 the former reports
VERSION_ID=7, while/etc/centos-releasereports7.9.2009.Both files are analyzed concurrently, and
OS.MergefilledNameonly while it was still empty, so the reported version depended on which analyzer merged first.In practice the winner is decided by the order of the entries in the layer tar, which normally puts
/etc/centos-releasefirst.That order is not part of the contract though.
Rebuilding the same layer with
/etc/os-releasemoved ahead of/etc/centos-release— with the contents of every file unchanged — flips the reported version to7in 100% of runs.Changes
OS.Mergenow keeps the more specific version when both sources describe the same family: a new name replaces the current one when the current one is a dotted prefix of it.CentOS is the only distribution affected in practice — Rocky, Alma, Oracle, RHEL and Fedora put the full
x.yversion intoVERSION_ID, so their sources already agree.Example
Before / after, same image with
/etc/os-releaseplaced first in the layer tar:Before:
After:
Related issues
Checklist