Skip to content

Commit 98e8208

Browse files
Merge pull request #156 from yuravk/almalinux-ng-0.24.0
checkmicroarchitecture: allow AlmaLinux 10 x86-64-v2 targets
2 parents 2a1f8a3 + aace80a commit 98e8208

3 files changed

Lines changed: 47 additions & 19 deletions

File tree

repos/system_upgrade/common/actors/checkmicroarchitecture/actor.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ class CheckMicroarchitecture(Actor):
2020
CPU compatible with ``x86-64-v2`` instruction set or higher. Similarly,
2121
RHEL10 requires at least ``x86-64-v3`` instruction set.
2222
23+
AlmaLinux 10 is additionally built for the ``x86-64-v2`` microarchitecture
24+
level, so when the upgrade target distro is AlmaLinux the requirement for
25+
the target major version 10 is kept at ``x86-64-v2``.
26+
2327
.. table:: Required CPU features by microarchitecure level with a
2428
corresponding flag as shown by ``lscpu``.
2529

repos/system_upgrade/common/actors/checkmicroarchitecture/libraries/checkmicroarchitecture.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from collections import namedtuple
22

33
from leapp import reporting
4+
from leapp.libraries.common.config import get_target_distro_id
45
from leapp.libraries.common.config.architecture import ARCH_X86_64, matches_architecture
56
from leapp.libraries.common.config.version import get_target_major_version
67
from leapp.libraries.common.distro import DISTRO_REPORT_NAMES
@@ -60,16 +61,30 @@ def process():
6061
url='https://red.ht/rhel-10-intel-microarchitectures'
6162
)
6263

63-
rhel_major_to_microarch_reqs = {
64-
'9': MicroarchInfo(microarch_ver='x86-64-v2',
65-
required_flags=(X86_64_BASELINE_FLAGS + X86_64_V2_FLAGS),
66-
extra_report_fields=[rhel9_microarch_article]),
67-
'10': MicroarchInfo(microarch_ver='x86-64-v3',
68-
required_flags=(X86_64_BASELINE_FLAGS + X86_64_V2_FLAGS + X86_64_V3_FLAGS),
69-
extra_report_fields=[rhel10_microarch_article]),
70-
}
71-
72-
microarch_info = rhel_major_to_microarch_reqs.get(get_target_major_version())
64+
# AlmaLinux 10 is additionally built for the x86-64-v2 microarchitecture
65+
# level, so the baseline requirement for AlmaLinux targets stays at v2
66+
# regardless of the major version. For RHEL/CentOS Stream 10 the
67+
# requirement is x86-64-v3 (RHEL 10 dropped support for v2).
68+
if get_target_distro_id() == 'almalinux':
69+
major_to_microarch_reqs = {
70+
'9': MicroarchInfo(microarch_ver='x86-64-v2',
71+
required_flags=(X86_64_BASELINE_FLAGS + X86_64_V2_FLAGS),
72+
extra_report_fields=[rhel9_microarch_article]),
73+
'10': MicroarchInfo(microarch_ver='x86-64-v2',
74+
required_flags=(X86_64_BASELINE_FLAGS + X86_64_V2_FLAGS),
75+
extra_report_fields=[]),
76+
}
77+
else:
78+
major_to_microarch_reqs = {
79+
'9': MicroarchInfo(microarch_ver='x86-64-v2',
80+
required_flags=(X86_64_BASELINE_FLAGS + X86_64_V2_FLAGS),
81+
extra_report_fields=[rhel9_microarch_article]),
82+
'10': MicroarchInfo(microarch_ver='x86-64-v3',
83+
required_flags=(X86_64_BASELINE_FLAGS + X86_64_V2_FLAGS + X86_64_V3_FLAGS),
84+
extra_report_fields=[rhel10_microarch_article]),
85+
}
86+
87+
microarch_info = major_to_microarch_reqs.get(get_target_major_version())
7388
if not microarch_info:
7489
api.current_logger().info(
7590
'No known microarchitecture requirements are known'

repos/system_upgrade/common/actors/checkmicroarchitecture/tests/test_checkmicroarchitecture.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,17 @@ def test_not_x86_64_passes(monkeypatch, arch):
3030

3131

3232
@pytest.mark.parametrize(
33-
('target_ver', 'cpu_flags'),
33+
('target_ver', 'cpu_flags', 'dst_distro'),
3434
[
35-
('9.0', ENTIRE_V2_FLAG_SET),
36-
('10.0', ENTIRE_V3_FLAG_SET)
35+
('9.0', ENTIRE_V2_FLAG_SET, 'rhel'),
36+
('10.0', ENTIRE_V3_FLAG_SET, 'rhel'),
37+
('9.0', ENTIRE_V2_FLAG_SET, 'almalinux'),
38+
# AlmaLinux 10 is built for x86-64-v2 as well, so v2 flags are enough
39+
('10.0', ENTIRE_V2_FLAG_SET, 'almalinux'),
40+
('10.0', ENTIRE_V3_FLAG_SET, 'almalinux'),
3741
]
3842
)
39-
def test_valid_microarchitecture(monkeypatch, target_ver, cpu_flags):
43+
def test_valid_microarchitecture(monkeypatch, target_ver, cpu_flags, dst_distro):
4044
"""
4145
Test no report is generated on a valid microarchitecture
4246
"""
@@ -45,6 +49,7 @@ def test_valid_microarchitecture(monkeypatch, target_ver, cpu_flags):
4549
monkeypatch.setattr(api, 'current_logger', logger_mocked())
4650

4751
monkeypatch.setattr(api, 'current_actor', CurrentActorMocked(arch=ARCH_X86_64, dst_ver=target_ver,
52+
dst_distro=dst_distro,
4853
msgs=[CPUInfo(flags=cpu_flags)]))
4954

5055
checkmicroarchitecture.process()
@@ -54,21 +59,25 @@ def test_valid_microarchitecture(monkeypatch, target_ver, cpu_flags):
5459

5560

5661
@pytest.mark.parametrize(
57-
('target_ver', 'cpu_flags'),
62+
('target_ver', 'cpu_flags', 'dst_distro'),
5863
(
59-
('9.0', checkmicroarchitecture.X86_64_BASELINE_FLAGS),
60-
('10.0', ENTIRE_V2_FLAG_SET),
64+
('9.0', checkmicroarchitecture.X86_64_BASELINE_FLAGS, 'rhel'),
65+
('10.0', ENTIRE_V2_FLAG_SET, 'rhel'),
66+
('9.0', checkmicroarchitecture.X86_64_BASELINE_FLAGS, 'almalinux'),
67+
# AlmaLinux 10 still requires v2 as the baseline
68+
('10.0', checkmicroarchitecture.X86_64_BASELINE_FLAGS, 'almalinux'),
6169
)
6270
)
63-
def test_invalid_microarchitecture(monkeypatch, target_ver, cpu_flags):
71+
def test_invalid_microarchitecture(monkeypatch, target_ver, cpu_flags, dst_distro):
6472
"""
6573
Test report is generated on x86-64 architecture with invalid microarchitecture and the upgrade is inhibited
6674
"""
6775
cpu_info = CPUInfo(flags=cpu_flags)
6876
monkeypatch.setattr(reporting, "create_report", create_report_mocked())
6977
monkeypatch.setattr(api, 'current_logger', logger_mocked())
7078
monkeypatch.setattr(api, 'current_actor',
71-
CurrentActorMocked(arch=ARCH_X86_64, msgs=[cpu_info], dst_ver=target_ver))
79+
CurrentActorMocked(arch=ARCH_X86_64, msgs=[cpu_info], dst_ver=target_ver,
80+
dst_distro=dst_distro))
7281

7382
checkmicroarchitecture.process()
7483

0 commit comments

Comments
 (0)