Skip to content

Commit

Permalink
Add logic to PR checker to detect kernel upgrade for OOT module specs (
Browse files Browse the repository at this point in the history
  • Loading branch information
ellie-di authored Jan 17, 2025
1 parent d7bc078 commit 586efce
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 6 deletions.
2 changes: 2 additions & 0 deletions SPECS/fwctl/fwctl.spec
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
# SOFTWARE.
#

%global last-known-kernel 6.6.64.2

%{!?_name: %define _name fwctl}
%{!?_version: %define _version 24.10}
%{!?_release: %define _release OFED.24.10.0.6.7.1}
Expand Down
2 changes: 2 additions & 0 deletions SPECS/iser/iser.spec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#
#

%global last-known-kernel 6.6.64.2

%if 0%{azl}
%global target_kernel_version_full %(/bin/rpm -q --queryformat '%{VERSION}-%{RELEASE}' kernel-headers)
%else
Expand Down
2 changes: 2 additions & 0 deletions SPECS/isert/isert.spec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#
#

%global last-known-kernel 6.6.64.2

%if 0%{azl}
%global target_kernel_version_full %(/bin/rpm -q --queryformat '%{VERSION}-%{RELEASE}' kernel-headers)
%else
Expand Down
2 changes: 2 additions & 0 deletions SPECS/knem/knem.spec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
# KMP is disabled by default
%{!?KMP: %global KMP 0}

%global last-known-kernel 6.6.64.2

%if 0%{azl}
%global target_kernel_version_full %(/bin/rpm -q --queryformat '%{VERSION}-%{RELEASE}' kernel-headers)
%else
Expand Down
1 change: 1 addition & 0 deletions SPECS/mft_kernel/mft_kernel.spec
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
%global last-known-kernel 6.6.64.2

%if 0%{azl}
%global target_kernel_version_full %(/bin/rpm -q --queryformat '%{VERSION}-%{RELEASE}' kernel-headers)
Expand Down
2 changes: 2 additions & 0 deletions SPECS/mlnx-nfsrdma/mlnx-nfsrdma.spec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#
#

%global last-known-kernel 6.6.64.2

%if 0%{azl}
%global target_kernel_version_full %(/bin/rpm -q --queryformat '%{VERSION}-%{RELEASE}' kernel-headers)
%else
Expand Down
5 changes: 3 additions & 2 deletions SPECS/mlnx-ofa_kernel/mlnx-ofa_kernel.spec
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
# and/or other materials provided with the distribution.
#
#
%global last-known-kernel 6.6.64.2

%if 0%{azl}
%global target_kernel_version_full %(/bin/rpm -q --queryformat '%{VERSION}-%{RELEASE}' kernel-headers)
Expand Down Expand Up @@ -147,7 +148,7 @@ Requires: ofed-scripts
BuildRequires: %kernel_module_package_buildreqs
BuildRequires: /usr/bin/perl
%endif
%description
%description
InfiniBand "verbs", Access Layer and ULPs.
Utilities rpm.
The driver sources are located at: http://www.mellanox.com/downloads/ofed/mlnx-ofa_kernel-24.10-0.7.0.tgz
Expand Down Expand Up @@ -324,7 +325,7 @@ export NAME=%{name}
export VERSION=%{version}
export PREFIX=%{_prefix}
mkdir -p %{buildroot}/%{_prefix}/src/ofa_kernel/%{_arch}
for flavor in %flavors_to_build; do
for flavor in %flavors_to_build; do
export KSRC=%{kernel_source $flavor}
export KVERSION=%{kernel_release $KSRC}
cd $PWD/obj/$flavor
Expand Down
2 changes: 2 additions & 0 deletions SPECS/srp/srp.spec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#
#

%global last-known-kernel 6.6.64.2

%if 0%{azl}
%global target_kernel_version_full %(/bin/rpm -q --queryformat '%{VERSION}-%{RELEASE}' kernel-headers)
%else
Expand Down
3 changes: 2 additions & 1 deletion SPECS/xpmem/xpmem.spec
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
%{!?KMP: %global KMP 0}

%global last-known-kernel 6.6.64.2

%if 0%{azl}
%global target_kernel_version_full %(/bin/rpm -q --queryformat '%{VERSION}-%{RELEASE}' kernel-headers)
%else
Expand Down Expand Up @@ -248,4 +250,3 @@ fi
* Tue Dec 17 2024 Binu Jose Philip <[email protected]>
- Initial Azure Linux import from NVIDIA (license: GPLv2)
- License verified

49 changes: 46 additions & 3 deletions toolkit/scripts/check_entangled_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,21 @@
])
]

# OOT kernel module specs to match the `last-known-kernel` with kernel-headers `version`
oot_kmodule_matching_groups = [
frozenset([
"SPECS/fwctl/fwctl.spec",
"SPECS/iser/iser.spec",
"SPECS/isert/isert.spec",
"SPECS/knem/knem.spec",
"SPECS/mft_kernel/mft_kernel.spec",
"SPECS/mlnx-nfsrdma/mlnx-nfsrdma.spec",
"SPECS/mlnx-ofa_kernel/mlnx-ofa_kernel.spec",
"SPECS/srp/srp.spec",
"SPECS/xpmem/xpmem.spec"
])
]

def check_spec_tags(base_path: str, tags: List[str], groups: List[FrozenSet]) -> Set[FrozenSet]:
"""Returns spec sets which violate matching rules for given tags. """
err_groups = set()
Expand All @@ -141,6 +156,21 @@ def check_spec_tags(base_path: str, tags: List[str], groups: List[FrozenSet]) ->
return err_groups


def check_oot_kmodules(base_path: str, tag: str, groups: List[FrozenSet]) -> Set[FrozenSet]:
"""Returns OOT kernel modules which violate matching with kernel-headers version. """
err_groups = set()

kernel_headers_spec = Spec.from_file(path.join(base_path, "SPECS/kernel-headers/kernel-headers.spec"))
kernel_headers_version = get_tag_value(kernel_headers_spec, 'version')

for group in groups:
for spec_filename in group:
parsed_spec = Spec.from_file(path.join(base_path, spec_filename))
tag_value = get_tag_value(parsed_spec, tag)
if tag_value != kernel_headers_version:
err_groups.add(spec_filename)
return err_groups

def check_mstflintver_match_groups(base_path: str) -> Set[FrozenSet]:
return check_spec_tags(base_path, ['mstflintver'], mstflintver_matching_groups)

Expand All @@ -153,16 +183,23 @@ def check_version_release_match_groups(base_path: str) -> Set[FrozenSet]:
def check_version_match_groups(base_path: str) -> Set[FrozenSet]:
return check_spec_tags(base_path, ['epoch', 'version'], version_matching_groups)

def check_oot_kmodule_matching_groups(base_path: str) -> Set[FrozenSet]:
return check_oot_kmodules(base_path, 'last-known-kernel', oot_kmodule_matching_groups)

def check_matches(base_path: str):
version_match_errors = check_version_match_groups(base_path)
version_release_match_errors = check_version_release_match_groups(base_path)
sdkver_match_errors = check_sdkver_match_groups(base_path)
mstflintver_match_errors = check_mstflintver_match_groups(base_path)
oot_kmodule_match_errors = check_oot_kmodule_matching_groups(base_path)

printer = pprint.PrettyPrinter()

if len(version_match_errors) or len(version_release_match_errors) or len(sdkver_match_errors) or len(mstflintver_match_errors):
if len(version_match_errors) or \
len(version_release_match_errors) or \
len(sdkver_match_errors) or \
len(mstflintver_match_errors) or \
len(oot_kmodule_match_errors):
print('The current repository state violates a spec entanglement rule!')

if len(version_match_errors):
Expand All @@ -182,13 +219,19 @@ def check_matches(base_path: str):
'\nPlease update the following sets of specs to have the same "sdkver" global variables:')
for e in sdkver_match_errors:
printer.pprint(e)

if len(mstflintver_match_errors):
print(
'\nPlease update the following sets of specs to have the same "mstflintver" global variables:')
for e in mstflintver_match_errors:
printer.pprint(e)


if len(oot_kmodule_match_errors):
print(
'\nPlease update the following sets of specs to match the "last-known-kernel" global variable with kernel-headers "version":')
for e in oot_kmodule_match_errors:
printer.pprint(e)

sys.exit(1)


Expand Down

0 comments on commit 586efce

Please sign in to comment.