Skip to content
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

[1.28] New dmidecode-based DMI facts collector; use it on aarch64 #3216

Merged
merged 7 commits into from
Mar 1, 2023

Conversation

ptoscano
Copy link
Contributor

The python-dmidecode module has currently not received work upstream in the last 7 years, and it starts to fails in some situations (e.g. Kernel Lockdown, when /dev/mem cannot be read). Hence, we cannot keep using python-dmidecode anymore.

As way forward, create a parser to parse the output of dmidecode(1), and a fact collector that uses this parser to provide "dmi.*" facts.
The parser and the facts collector are tested using collected outputs (and anonymized) of dmidecode(1), so it is easy to check whether changes will break existing outputs.

Cloud-what has its own facts collector using python-dmidecode in case subscription-manager is not installed. In it, manually query dmidecode(1) for known DMI strings used by the cloud detection, so it should work in that case too.

The dmidecode is available on ARM64. Thus it make sense to use same approach, which is used on x86_64 platform and
parse output of dmidecode(1).

Please refer to the individual commits for few more explanations.

BZ: https://bugzilla.redhat.com/show_bug.cgi?id=2173583
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=2109365 (fixed by dropping the old code)

Backport of:

@github-actions
Copy link

github-actions bot commented Feb 28, 2023

Coverage

Coverage (computed on Fedora latest) •
FileStmtsMissCoverMissing
cloud_what
   fact_collector.py68680%17, 24–27, 29, 32, 37–38, 40, 46–48, 50–54, 56–57, 59, 61, 64, 66–67, 69, 71, 73, 79–80, 82, 84–88, 90, 92, 97–99, 102, 115–120, 122–125, 129–132, 137–138, 140–141, 143–147, 149–151
   setup.py330%17, 21, 23
rhsmlib/facts
   dmidecodeparser.py145993%116–117, 119–120, 123–126, 249
   dmiinfo.py56492%52–55
   firmware_info.py30196%39
TOTAL22825992356% 

Tests Skipped Failures Errors Time
2339 10 💤 0 ❌ 0 🔥 5m 47s ⏱️

ptoscano and others added 7 commits March 1, 2023 11:37
The python-dmidecode module has currently not received work upstream in
the last 7 years, and it starts to fails in some situations (e.g. Kernel
Lockdown, when /dev/mem cannot be read).

As way around that, switch the MiniHostCollector facts collector to
invoke the dmidecode(1) tool instead to get some facts from known DMI
strings.

The general result of the detection should still be the same, as the
fetched strings are used (or potentially used) during the cloud
detection by the providers. Also, this fact detector is used only when
subscription-manager is not installed, so the impact should be minimal.

Adapt the buildsystem & packaging bits to require dmidecode for
cloud-what rather than the Python module dmidecode.

(cherry picked from commit 9422d24)
Create a new parser for parsing the output of the dmidecode(1) tool,
collecting all the data from it. Add a test for it with existing outputs
to check, as dmidecode information can be read only as root, and they
would change on each system. The data-based tests check that the parser
works fine, and extracts at least the system UUID.
The test data have sensible details (UUIDs, serial numbers, product
names, and part numbers) replaced with placeholders; this also helps
testing that the parsed output contains the values we expect.

In addition to that, add a facts collector that uses this new parser;
to make sure the facts resemble somehow what the python-dmidecode-based
one returns, do few quirks to adapt the data read from dmidecode(1).
Add a test for this new collector, using the aforementioned test data,
and checking that at least some subtags of "dmi" facts are collected.

(cherry picked from commit b100b50)
Use the new DmidecodeFactCollector to collect the DMI facts, rather than
DmiFirmwareInfoCollector (that uses python-dmidecode).

Switches the requirement of subscription-manager from python-dmidecode
(not available on SUSE distros) to dmidecode unconditionally (available
on any modern distro).

(cherry picked from commit 9253695)
Drop the facts collector based on python-dmidecode, as it is no more
used now.

(cherry picked from commit e969e2f)
subscription-manager itself does not use python-dmidecode anymore now.
Also, python-dmidecode is not available in SUSE distros, exactly where
this plugin is supposed to run.

Hence, drop the dmidecode warnings cleaning, as it is effectively dead
code.

(cherry picked from commit 617048e)
The function was not using the parameter it was being passed, but some
other local variable at its scope. Changing the name to ensure the right
string is compared.

(cherry picked from commit 2ef4d87)
* Card ID: ENT-5112
* The dmidecode is available on ARM64. Thus it make sense to
  use same approach, which is used on x86_64 platform and
  parse output of dmidecode
* Old code and old tests were dropped
* subscription-manager.spec file was modified

(cherry picked from commit ddf4d6f)
@jirihnidek jirihnidek self-assigned this Mar 1, 2023
Copy link
Contributor

@jirihnidek jirihnidek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM: I can confirm that it works on x86_64 and aarch64.

@jirihnidek jirihnidek merged commit ae3d993 into subscription-manager-1.28 Mar 1, 2023
@jirihnidek jirihnidek deleted the ptoscano/2173583-1.28 branch March 1, 2023 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants