-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix OS grain inconsistencies if lsb-release is installed or not #61626
Conversation
e64d00c
to
1be251f
Compare
Added the fix for Astra Linux. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bdrung Can you resolve the conflicts for the two files and update.
Going through the changes etc., but need the conflicts resolved regardless.
1be251f
to
da338c2
Compare
Pull request #61619 got merged. I rebased this merge request on master now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to fix the Lint errors before reviewing
Update: And now the failing tests
Some test cases fail due to #62220 (comment) |
da338c2
to
f9e657f
Compare
Lint errors are unrelated to this PR. |
This should fix things #62790 |
34e7f06
to
6df7275
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to merge once all the failing tests are resolved
re-run all |
The failing tests might be related.
|
@bdrung Just making sure you saw the failing tests on this PR and that they seem to be related to your changes. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bdrung Are you still interested in this PR ?, the 3 failing Debian tests need fixing.
…8_chars `freedesktop_os_release` must return a dictionary containing at least `NAME`, `ID`, and `PRETTY_NAME` or raise an `OSError`. Fix the mock in `test_linux_proc_files_with_non_utf8_chars` to return a minimal dictionary instead of an empty mock. Signed-off-by: Benjamin Drung <[email protected]>
Replace `lsb_distrib_release` by `osrelease` in the tests to avoid needing to set the lsb_* values. Signed-off-by: Benjamin Drung <[email protected]>
74e4181
to
5b22c18
Compare
Signed-off-by: Benjamin Drung <[email protected]>
Most Linux distributions ship an os-release file by default. Some do not ship lsb-release information, but they can be installed afterwards. Installing/Removing lsb-release can lead to different OS grain values. | OS | grain | without lsb-release | with lsb-release | |------------------|------------|----------------------------------|------------------| | AlmaLinux 8 | oscodename | AlmaLinux 8.5 (Arctic Sphynx) | ArcticSphynx | | Astra CE | os | Astra (Orel) | AstraLinuxCE | | Astra CE | os_family | Astra (Orel) | Debian | | Astra CE | osfullname | Astra Linux (Orel) | AstraLinuxCE | | Astra CE 2.12.40 | osfinger | Astra Linux (Orel)-2 | AstraLinuxCE-2 | | Debian | osfullname | Debian GNU/Linux | Debian | | Mendel | osfullname | Mendel GNU/Linux | Mendel | | Mendel 10 | osfinger | Mendel GNU/Linux-10 | Mendel-10 | | Mint | osfullname | Linux Mint | Linuxmint | | Mint 20.3 | osfinger | Linuxmint-20 | Linux Mint-20 | | Pop | osfullname | Pop!_OS | Pop | | Pop 20.04 | osfinger | Pop!_OS-20 | Pop-20 | | Rocky | osfullname | Rocky Linux | Rocky | | Rocky 8 | osfinger | Rocky Linux-8 | Rocky-8 | | Rocky 8 | oscodename | Rocky Linux 8.5 (Green Obsidian) | GreenObsidian | The current code that determines the OS grains on Linux is a mess: First lsb-release is queried. If that fails, fall back to read os-release and parse some `/etc/*-release` files. Then query `_linux_distribution` and use a mixtures of those for the OS grains. `_linux_distribution` queries the Python `distro` library. `distro` queries the os-release file, lsb-release, and then `/etc/*-release`. Rewrite the code that determines the OS grains on Linux. Solely rely on the data provided by the os-release file. To not cause regressions, only switch the distribution that has been tested. All other distributions will use the legacy code (which was moved to `_legacy_linux_distribution_data`). The new code derives the `os_family` grain from the `ID_LIKE` field from os-release (see saltstack#59061 for this feature request). To enable this feature, the new code needs to be used by default (and not just for selected distributions). This commit introduces a few changes to the OS grains: * AlmaLinux and Rocky Linux extract the codename from the `VERSION` field now instead of using the full `PRETTY_NAME`. * Mendel uses now `Mendel GNU/Linux` as `osfullname` and correctly extracts the `osrelease` from `PRETTY_NAME`. * Pop!_OS changes the `osfullname` from `Pop` to `Pop!_OS`. * Astra Linux changes the `osfullname` from `AstraLinuxCE` to `Astra Linux (Orel)` and `AstraLinuxSE` to `Astra Linux (Smolensk)` respectively. Fixes saltstack#61618 Signed-off-by: Benjamin Drung <[email protected]>
Some distribution derive the OS grains purely from os-release information and therefore `_linux_distribution` is not called any more. So remove the test data for unused code paths. Signed-off-by: Benjamin Drung <[email protected]>
5b22c18
to
43996e0
Compare
Fixed failing Debian tests. |
Most Linux distributions ship an os-release file by default. Some do not ship lsb-release information, but they can be installed afterwards. Installing/Removing lsb-release can lead to different OS grain values.
The current code that determines the OS grains on Linux is a mess: First lsb-release is queried. If that fails, fall back to read os-release and parse some
/etc/*-release
files. Then query_linux_distribution
and use a mixtures of those for the OS grains._linux_distribution
queries the Pythondistro
library.distro
queries the os-release file, lsb-release, and then/etc/*-release
.Rewrite the code that determines the OS grains on Linux. Solely rely on the data provided by the os-release file. To not cause regressions, only switch the distribution that has been tested. All other distributions will use the legacy code (which was moved to
_legacy_linux_distribution_data
).The new code derives the
os_family
grain from theID_LIKE
field from os-release (see #59061 for this feature request). To enable this feature, the new code needs to be used by default (and not just for selected distributions).This commit introduces a few changes to the OS grains:
VERSION
field now instead of using the fullPRETTY_NAME
.Mendel GNU/Linux
asosfullname
and correctly extracts theosrelease
fromPRETTY_NAME
.osfullname
fromPop
toPop!_OS
.osfullname
fromAstraLinuxCE
toAstra Linux (Orel)
andAstraLinuxSE
toAstra Linux (Smolensk)
respectively.Fixes #61618
This merge request contains the commits from the merge request #61597, #61589, and #61619. So I recommend to review and merge those first.