Feature: Adding Azure Linux 4.0 Base Support using dnf5 package manager#343
Feature: Adding Azure Linux 4.0 Base Support using dnf5 package manager#343yashnap wants to merge 9 commits into
Conversation
7ddf13b to
c615038
Compare
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Introduces an Azure Linux 4–specific DNF (dnf5) package manager implementation and wires it into distro/package-manager detection so Azure Linux 4 selects DNF instead of TDNF.
Changes:
- Added
AzL4DnfPackageManagerskeleton class extendingPackageManager. - Updated Azure Linux package manager detection to choose DNF for Azure Linux 4+ and TDNF for Azure Linux 3.
- Added
Constants.DNFand registered DNF configurations inConfigurationFactory.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/core/src/package_managers/AzL4DnfPackageManager.py |
Adds a new (currently stubbed) DNF-based package manager for Azure Linux 4. |
src/core/src/bootstrap/EnvLayer.py |
Selects DNF for Azure Linux 4+ and keeps TDNF for Azure Linux 3. |
src/core/src/bootstrap/Constants.py |
Introduces a DNF constant used by configuration selection. |
src/core/src/bootstrap/ConfigurationFactory.py |
Registers DNF configs and maps them to AzL4DnfPackageManager. |
Comments suppressed due to low confidence (1)
src/core/src/bootstrap/EnvLayer.py:1
- This error path drops useful diagnostics. Consider including the command result (
out) and/or the checked path in the message so failures are actionable (e.g., whendnfis installed but not on PATH). Also, returningstr()(empty string) makes it hard to distinguish 'not found' vs 'unknown'; consider returningNoneor a dedicated sentinel, depending on existing conventions in this module.
# Copyright 2020 Microsoft Corporation
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def refresh_repo(self): | ||
| """Refreshes the DNF repository cache and lists available updates by cleaning expired cache entries | ||
| Commands: | ||
| - sudo dnf clean expire-cache (cleans expired cache entries) | ||
| - sudo dnf -q check-update (checks for available updates) | ||
| """ | ||
| pass |
| def get_all_updates(self, cached=False): | ||
| """Gets all missing updates available for the system and returns the cached updates list and versions list | ||
| Cache Check Logic: | ||
| - If cached=True and cache has data, return cached updates and versions immediately (high performance reuse) | ||
| - If cache miss or cached=False, execute the DNF command to get fresh updates and populate cache | ||
| Command: | ||
| - sudo dnf -q check-update (checks for all available updates) | ||
| 1. If cached=True and cache has data, return cached results | ||
| 2. Execute command, parse output, cache results | ||
| 3. Return all_updates_cached and all_update_versions_cached | ||
| """ | ||
| return [], [] | ||
|
|
||
| # AssessPatch method | ||
| def get_security_updates(self): | ||
| """Gets all missing security updates available for the system and returns packages and versions list | ||
| Command: | ||
| - sudo dnf -q check-update --security (checks for available security updates only) | ||
| Returns: | ||
| - List of security package names | ||
| - List of corresponding security package versions | ||
| """ | ||
| pass |
| if major is not None and int(major) >= 4: | ||
| code, out = self.run_command_output('which dnf', False, False) | ||
| if code == 0: | ||
| return 'dnf' |
| """ | ||
| return [], [] | ||
|
|
||
| def set_max_patch_publish_date(self, max_patch_publish_date=str()): |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #343 +/- ##
==========================================
- Coverage 93.84% 92.99% -0.85%
==========================================
Files 105 107 +2
Lines 18218 18731 +513
==========================================
+ Hits 17096 17419 +323
- Misses 1122 1312 +190
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:
|
b081d06 to
1b80cf7
Compare
0a05123 to
9b9fd31
Compare
6fdc513 to
d42304e
Compare
d42304e to
b950de5
Compare
|
|
||
| from core.src.package_managers.AptitudePackageManager import AptitudePackageManager | ||
| from core.src.package_managers.AzL3TdnfPackageManager import AzL3TdnfPackageManager | ||
| from core.src.package_managers.DnfPackageManager import DnfPackageManager |
There was a problem hiding this comment.
updated naming everywhere with dnf5
|
|
||
| self.configurations = { | ||
| 'apt_prod_config': self.new_prod_configuration(Constants.APT, AptitudePackageManager), | ||
| 'dnf_prod_config': self.new_prod_configuration(Constants.DNF, DnfPackageManager), |
|
|
||
| # Package Managers | ||
| APT = 'apt' | ||
| DNF = 'dnf' |
| # | ||
| # Requires Python 2.7+ | ||
|
|
||
| """DnfPackageManager for Azure Linux L4 and RHEL 10""" |
There was a problem hiding this comment.
Do not mention the image restrictions within packagemanager. Restrictions would only come from the places where it is set/invoked and not within the package manager implementation.
There was a problem hiding this comment.
Removed image restrictions.
|
|
||
|
|
||
| class DnfPackageManager(PackageManager): | ||
| """Implementation of Azure Linux L4/RHEL 10 DNF5 package management operations""" |
There was a problem hiding this comment.
Same comment as on line 17
| return Constants.AutomaticOSPatchStates.DISABLED | ||
|
|
||
| if enable_on_reboot_value: | ||
| return Constants.AutomaticOSPatchStates.ENABLED |
There was a problem hiding this comment.
What if apply_updates_value is enabled?
|
|
||
| if enable_on_reboot_value: | ||
| return Constants.AutomaticOSPatchStates.ENABLED | ||
|
|
There was a problem hiding this comment.
Can you map out a matrix on all the possible values of: is_service_installed, enable_on_reboot_value, download_updates_value, apply_updates_value and how it affects auto_os_patch_state_for_dnf5_automatic?
There was a problem hiding this comment.
Added in the document
| enable_on_reboot_value = self.is_service_set_to_enable_on_reboot(self.enable_on_reboot_check_cmd) | ||
|
|
||
| self.composite_logger.log_debug( | ||
| "[DNF] Checking if auto updates are currently enabled...") |
| except Exception as error: | ||
| raise Exception( | ||
| "[DNF] Error occurred in fetching current auto OS update settings from the machine (dnf5). [Exception={0}]".format( | ||
| repr(error))) |
There was a problem hiding this comment.
Enabling and disabling Auto OS updates is slightly more involved than what is implemented here. There's more checks and balances that are missed. Will try to cover it in offline sync.
But a suggestion here is, try to closely follow what is already implemented in tdnf, it will be same or very similar for dnf. Create an AzL3 VM, see how auto OS update works in it, you can try running the cmds in it to understand what is happening and then re-create the process for AzL4
| package_manager.get_current_auto_os_patch_state = self.runtime.backup_get_current_auto_os_patch_state | ||
|
|
||
| # Mock the systemctl cat output with enabled flags | ||
| systemctl_cat_output = '''[Unit] |
There was a problem hiding this comment.
Refer existing UTs on how mocks are implemented within the code base
There was a problem hiding this comment.
I am adding UTs to cover all scenarios . Will review the existing code on how it done.
| self.install_check_cmd = self.dnf5_automatic_install_check_cmd | ||
| self.current_auto_os_update_service = self.dnf5_auto_os_update_service | ||
|
|
||
| def __get_current_auto_os_updates_setting_on_machine(self): |
| def test_refresh_repo(self): | ||
| self.runtime.set_legacy_test_type('HappyPath') | ||
| package_manager = self.container.get('package_manager') | ||
| self.assertTrue(package_manager is not None) |
|
Note: Renamed the DNfPackageManager file to DNF5 =PackageManager along with code updates, which caused Git to show it as a delete + add. The logic changes are incremental, but previous comments may appear outdated due to this artifact. |

Implemented DnfPackageManager by extending PackageManager instead of TdnfPackageManager.
DNF5 behavior (output, classification, dependency resolution) differs from Tdnf making reuse unsafe. This approach keeps the implementation clean with dnf5 capabilities.
FIRST ITERATION ( Enablement/Disablement)
Implemented the below methods:
get_current_auto_os_patch_state,
disable_auto_os_update,
disable_auto_os_update_for_dnf5_automatic,
disable_auto_update_on_reboot,
is_auto_update_service_installed,
is_service_set_to_enable_on_reboot,
enable_auto_update_on_reboot
Added few UT's to cover the implementation(more to follow)
TESTING
ARM ID : /subscriptions/6acc8a91-e2b0-4041-a069-c2932ab42fd9/resourceGroups/rg-yashna-linux4-test-wus2/providers/Microsoft.Compute/virtualMachines/vm-yashna-linux4
<--------------------ITERATION2------------------------->
output.txt
<------------------ITERATION3---------------->
Install Update package available
output.txt
All packages are upto date and already installed
output_alreadyUptoDate.txt