[Packaging] Azure CLI container based on Azure Linux 4.0 - #33850
[Packaging] Azure CLI container based on Azure Linux 4.0#33850mansoor sarfraz (msarfraz) wants to merge 9 commits into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
There was a problem hiding this comment.
Pull request overview
This PR updates the Azure Linux–based Azure CLI container/RPM build pipeline from Azure Linux 3.0 to Azure Linux 4.0 (beta), aligning the Docker build inputs, artifact naming, and documentation with the new base image and RPM output paths.
Changes:
- Switch the Azure Linux base image reference from
mcr.microsoft.com/azurelinux/base/core:3.0tomcr.microsoft.com/azurelinux-beta/base/core:4.0in build assets. - Update RPM output paths for Azure Linux builds to
/root/rpmbuild/RPMS/...to match current rpmbuild output layout. - Rename Azure Linux pipeline matrix labels and artifact names from
3.0to4.0for consistency.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| scripts/release/rpm/README.md | Updates the Azure Linux RPM extraction example to the Azure Linux 4.0 RPM name and rpmbuild output path. |
| scripts/release/rpm/pipeline_azurelinux.sh | Updates the inline guidance/example base image reference for Azure Linux builds to 4.0 beta. |
| scripts/release/rpm/azurelinux.dockerfile | Updates the default base image and adjusts expected/copied RPM output paths for Azure Linux 4.0. |
| azure-pipelines.yml | Updates Azure Linux pipeline jobs to use the 4.0 beta image and renames related artifacts from 3.0 to 4.0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Suppressed comments (3)
src/azure-cli-core/azure/cli/core/extension/operations.py:262
- The warning message has a grammar issue ("if not exist"), which is user-facing and makes the output harder to understand. Rephrase to "if not present" (or similar).
logger.warning(
'This extension depends on %s and they will be installed first if not exist.',
' '.join(rpm_packages)
)
src/azure-cli-core/azure/cli/core/extension/operations.py:220
get_linux_distro()can return(None, None)(e.g., missing/etc/os-releaseor missingVERSION_ID). Calling.lower()/.startswith()onNonewill raise, which would break extension install on some Linux environments. Coercedistname/distversionto empty strings before using them.
distname, distversion = get_linux_distro()
distname = distname.lower().strip()
is_azure_linux_4 = 'azure linux' in distname and distversion.startswith('4.')
scripts/release/rpm/azurelinux.dockerfile:32
find / -xdev ... | head -n 1scans the whole filesystem in the build container, which can be slow and occasionally brittle. Since the RPM should only be under the rpmbuild topdirs for AZL3/AZL4, restrict the search to those directories and use-quitto stop at the first match.
RPM_PATH=$(find / -xdev -type f -name "azure-cli-${cli_version}-1.*.rpm" 2>/dev/null | head -n 1) && \
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/azure-cli-core/azure/cli/core/extension/operations.py:257
- Azure Linux 4.x branch invokes
tdnfdirectly; iftdnfis not present,subprocess.callwill raiseFileNotFoundErrorand bypass the intendedCLIErrormessaging. Add an explicitshutil.which('tdnf')check (similar to the Homebrew branch’sbrewcheck) and fail fast with a clearCLIError.
elif is_azure_linux_4:
rpm_packages = ['gcc', 'libpq-devel', 'python3-devel', 'binutils', 'glibc-devel', 'kernel-headers']
rpm_install_cmd = ['tdnf', 'install', '-y'] + rpm_packages
if os.geteuid() != 0: # pylint: disable=no-member
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Suppressed comments (3)
src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py:498
- This assertion doesn't actually validate that yum wasn't used: the yum install command in
_install_deps_for_psycopg2usespostgresql-devel(and not the AZL package list), so thisassertNotInwill always pass even if the code accidentally calls yum. Consider asserting that none of the subprocess calls start withyum/sudo yuminstead.
azure_linux_packages = ['gcc', 'libpq-devel', 'python3-devel', 'binutils', 'glibc-devel', 'kernel-headers']
subprocess_call.assert_any_call(['tdnf', 'install', '-y'] + azure_linux_packages)
self.assertNotIn(mock.call(['yum', 'install', '-y'] + azure_linux_packages),
subprocess_call.call_args_list)
src/azure-cli-core/azure/cli/core/extension/operations.py:221
get_linux_distro()returnsversion_idfrom/etc/os-release, which may be'4'(no dot) or include surrounding whitespace. The currentstartswith('4.')check can miss Azure Linux 4 and skip installing psycopg2 build deps. Consider normalizingdistversionand checking major version more robustly.
distname, distversion = get_linux_distro()
distname = (distname or '').lower().strip()
distversion = distversion or ''
is_azure_linux_4 = 'azure linux' in distname and distversion.startswith('4.')
src/azure-cli-core/azure/cli/core/extension/operations.py:270
- The warning says the packages "will be installed ... if not present", but this branch always runs
tdnf installunconditionally. Either add an installed-check (like the DEB path does) or adjust the message to avoid implying conditional behavior.
logger.warning(
'This extension depends on %s and they will be installed first if not present.',
' '.join(rpm_packages)
)
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Suppressed comments (1)
scripts/release/rpm/azurelinux.dockerfile:32
- The
RPM_PATH=$(...) || RPM_PATH=""fallback is ineffective because a variable assignment returns a successful status, so the||branch will never run. Also,findcan exit non-zero when any of the searched base directories is missing, which can make this step brittle if the shell is ever run with-esemantics.
Simplify the assignment and explicitly ignore find failures while still allowing the later -z "$RPM_PATH" guard to handle the "not found" case.
RPM_PATH=$(find /usr/src/azl/RPMS /root/rpmbuild/RPMS -type f -name "azure-cli-${cli_version}-1.*.rpm" 2>/dev/null | head -n 1) || RPM_PATH="" && \
Azure Linux version is updated from 3.0 to 4.0(beta)
https://github.com/microsoft/azurelinux