Fix amzn2 tests pipeline#1486
Conversation
Steps to get the AL2 converted: yum install -y https://<CDN mirror>/content/dist/rhel/server/7/7Server/x86_64/os/Packages/p/python-dmidecode-3.12.2-2.el7.x86_64.rpm curl -o /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release https://security.access.redhat.com/data/fd431d51.txt curl -o /etc/yum.repos.d/client-tools-for-rhel-7-server.repo https://cdn-public.redhat.com/content/public/repofiles/client-tools-for-rhel-7-server.repo yum -y install subscription-manager subscription-manager register rm -f /etc/yum.repos.d/amzn2-extras.repo yum remove python3-* python2-s3transfer -y echo "allow_unavailable_kmods=true" >> /etc/convert2rhel.ini echo "skip_kernel_currency_check=true" >> /etc/convert2rhel.ini convert2rhel -y --debug
The --setopt=varsdir= option was introduced in dnf. For that reason we can't pass to yum a directory with yum variable files and instead we need to ensure that all necessary yum vars are defined in /etc/yum/vars.
And update grub settings so that convert2rhel can call grub2-mkconfig.
Assisted by GitHub Copilot
The target OS breadcrumbs (convert2rhel.facts and /etc/migration-results) incorrectly contained the original/source OS information in the target OS fields because the /etc/system-release file was not re-parsed after the conversion. And allow host-metering on a converted AL2 thanks to reparsing the /etc/system-release file to get to know it's RHEL 7 after the conversion.
Avoid repoquery -f on EL7 as it uses yum's searchPackageProvides which loads all package provides into memory, causing MemoryError on memory-constrained systems. Use kernel*/kmod* name-based patterns instead. Add --archlist to repoquery to restrict results to the current architecture. Treat AL2 (version.major == 2) the same as RHEL 7 for ELS eligibility. Update the AL2 config with additional excluded and swap packages needed for a clean conversion (e.g. python2-dateutil, python2-setuptools, amd-ucode-firmware) and sort the lists alphabetically. Fix several bugs introduced in earlier AL2 commits: - get_system_release_info() ignored the system_release_data parameter, causing target OS breadcrumbs to still show source OS information - get_kernel_availability() returned the yum return code instead of an empty list when no available packages were found - FixGrubSettingsOnAL2 modified /etc/default/grub without a RestorableFile backup, preventing rollback on conversion failure - Fix typos in comments and docstrings
Amazon Linux 2 does not ship /etc/sysconfig/kernel. The FixDefaultKernel action now detects the missing file and creates it with the correct DEFAULTKERNEL value (kernel for RHEL 7, kernel-core for RHEL 8+) instead of failing. A warning message is emitted when the file is created. Add unit test covering scenario of AL2 setup. This issue didn't break the conversion, but appears when attempt to upgrade converted system with Leapp.
Reviewer's GuideAdds full Amazon Linux 2 (amzn2) support and robustness improvements to the convert2rhel pipeline by refining system detection, kernel and GRUB handling, yum/dnf variable backup/restore, package/query helpers, and associated tests. Sequence diagram for yum variable backup, package removal, and restoresequenceDiagram
participant Conv as ConversionController
participant BUVar as BackUpYumVariables
participant PKG as pkghandler
participant Bkp as backup_backup_control
participant RmPkgs as RemoveSpecialPackages
participant RstVar as RestoreYumVarFiles
participant FS as Filesystem
Conv->>BUVar: run()
BUVar->>PKG: get_installed_pkg_objects(repofile_pkg)
PKG-->>BUVar: list of installed pkg objects
loop for each pkg_name
BUVar->>PKG: get_files_owned_by_package(pkg_name)
PKG-->>BUVar: list of paths
end
BUVar->>BUVar: _get_yum_var_files_owned_by_pkgs()
BUVar->>Bkp: push(RestorableFile(filepath))
Bkp-->>BUVar: ack
Conv->>RmPkgs: run()
RmPkgs->>PKG: remove_pkgs(pkgs_to_remove)
PKG->>FS: remove package files and yum var files
FS-->>PKG: done
Conv->>RstVar: run()
RstVar->>Bkp: get_backed_up_yum_var_dirs()
Bkp-->>RstVar: {orig_dir: backup_dir}
loop for each backed up var file
RstVar->>FS: copy2(backup_file, orig_dir)
FS-->>RstVar: file copied
RstVar->>Bkp: push(InstalledFile(restored_filepath))
Bkp-->>RstVar: ack
end
Class diagram for new yum variable backup and InstalledFile handlingclassDiagram
class RestorableChange {
<<abstract>>
+bool enabled
+enable()
+restore()
}
class RestorableFile {
+str filepath
+enable()
+restore()
}
class InstalledFile {
+str filepath
+enable()
+restore()
}
class BackupController {
+push(change)
+restore_all()
}
class BackUpYumVariables {
+str id
+list yum_var_dirs
+run()
-_get_yum_var_files_owned_by_pkgs(pkg_names)
-_back_up_var_files(paths)
}
class RestoreYumVarFiles {
+str id
+tuple dependencies
+run()
}
class pkghandler {
+get_installed_pkg_objects(name, version, release, arch)
+get_files_owned_by_package(installed_pkg_name)
}
class backup_module {
+backup_control : BackupController
+get_backedup_system_repos()
+get_backed_up_yum_var_dirs()
}
RestorableChange <|-- RestorableFile
RestorableChange <|-- InstalledFile
backup_module o-- BackupController
BackUpYumVariables --> backup_module : uses backup_control.push
BackUpYumVariables --> RestorableFile : creates
BackUpYumVariables --> pkghandler : uses get_installed_pkg_objects
BackUpYumVariables --> pkghandler : uses get_files_owned_by_package
RestoreYumVarFiles --> backup_module : uses get_backed_up_yum_var_dirs
RestoreYumVarFiles --> InstalledFile : creates
RestoreYumVarFiles --> backup_module : uses backup_control.push
Flow diagram for Amazon Linux 2 specific conversion logicflowchart TD
A[Start convert2rhel on source system] --> B[SystemInfo.parse_system_release_content reads /etc/system-release]
B --> C{version.major == 2}
C -- no --> Z[Proceed with standard RHEL or other distro flow]
C -- yes --> D[Load amazon-2-x86_64.cfg
system_info.repofile_pkgs includes system-release and amazon-linux-extras]
D --> E[Backup yum variables
BackUpYumVariables]
E --> F[Backup repositories and other pre PONR steps]
F --> G[Kernel checks
RhelCompatibleKernel]
G --> H{Kernel compatible with target RHEL version}
H -- no --> I[On AL2: log warning
INCOMPATIBLE_KERNEL_ON_AL2
allow continuation]
H -- yes --> J[Continue]
I --> J
J --> K[Conversion actions
package changes]
K --> L[RestoreYumVarFiles restores yum vars from backup]
L --> M[FixDefaultKernel
ensure /etc/sysconfig/kernel exists
set DEFAULTKERNEL]
M --> N[FixGrubSettingsOnAL2
if version.major == 2
update GRUB_TERMINAL]
N --> O[UpdateGrub rebuilds GRUB config]
O --> P[HostMeteringRun
reparse system release
check post conversion major version]
P --> Q[subscription.install_rhel_subscription_manager
uses client tools repofile URL for version.major 2]
Q --> R[SystemChecks.convert2rhel_latest
uses C2R_REPOFILE_URLS mapping for 2]
R --> S[Finish conversion with AL2 specific handling completed]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1486 +/- ##
==========================================
+ Coverage 96.11% 96.17% +0.05%
==========================================
Files 72 73 +1
Lines 5176 5309 +133
Branches 895 922 +27
==========================================
+ Hits 4975 5106 +131
- Misses 119 120 +1
- Partials 82 83 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
768004f to
faaef2e
Compare
|
/packit test --labels amzn2 |
1 similar comment
|
/packit test --labels amzn2 |
f5c8bb2 to
1498d6d
Compare
|
/packit test --labels amzn2 |
1498d6d to
8bd488f
Compare
|
/packit test --labels amzn2 |
8a66873 to
bcdc7b0
Compare
|
/packit test --labels amzn2 |
35a308e to
87c77ec
Compare
|
/packit test --labels amzn2 |
87c77ec to
c7e1dc5
Compare
c7e1dc5 to
0bc9664
Compare
|
/packit test --labels amzn2 |
0bc9664 to
7f7267f
Compare
|
/packit test --labels amzn2 |
7f7267f to
0c95f44
Compare
|
/packit test --labels amzn2 |
Use `repoquery --installed` when mapping package repository data to avoid hitting stale/inaccessible remote repos. Do cleanup of repo leftovers. Cover both of these functionalities with unit tests.
a312be0 to
c25c0e5
Compare
|
/packit test --labels amzn2 |
c25c0e5 to
8c283c0
Compare
|
/packit test --labels amzn2 |
8c283c0 to
67a4fab
Compare
|
/packit test --labels amzn2 |
67a4fab to
b209b4c
Compare
|
/packit test --labels amzn2 |
17a43ec to
e83b011
Compare
|
/packit test --labels amzn2 |
|
/packit test --labels sanity |
e83b011 to
1cabaef
Compare
1cabaef to
04cdbb3
Compare
|
/packit test --labels amzn2 |
|
/packit test --labels sanity |
* include amzn2 related vars in the tests * bump the tmt lint hook * reinstall test framework deps at the end of the convert2rhel fixture teardown * disable unrelated/incompatible tests Signed-off-by: Daniel Diblik <ddiblik@redhat.com>
* swap more rpms with available counterparts * exclude more amazon related undesired rpms * enable extras and optional repos by default for amzn2 Signed-off-by: Daniel Diblik <ddiblik@redhat.com>
* GRUB_DISTRIBUTOR and GRUB_DISABLE_SUBMENU are missing from the /etc/default/grub, add these to fix the format of the GRUB menu entries Signed-off-by: Daniel Diblik <ddiblik@redhat.com>
Signed-off-by: Daniel Diblik <ddiblik@redhat.com>
Signed-off-by: Daniel Diblik <ddiblik@redhat.com>
04cdbb3 to
944b464
Compare
Jira Issues:
Checklist
[RHELC-]or[HMS-]is part of the PR titleRelease Pendingif relevant