Skip to content

fix: deduplicate RPM selection in installRPMPackageFromFile for Azure Linux#8003

Merged
cameronmeissner merged 1 commit intomainfrom
fix/azl3-rpm-conflicting-requests
Mar 4, 2026
Merged

fix: deduplicate RPM selection in installRPMPackageFromFile for Azure Linux#8003
cameronmeissner merged 1 commit intomainfrom
fix/azl3-rpm-conflicting-requests

Conversation

@awesomenix
Copy link
Contributor

Problem

On Azure Linux V3 nodes, when multiple RPM release versions of the same package coexist in the download cache (e.g. kubectl-1.34.3-1.azl3.x86_64.rpm and kubectl-1.34.3-2.azl3.x86_64.rpm), both files were passed to dnf install, causing "conflicting requests" errors because both RPMs provide the same package at the same version.

The root cause is that find ... -print -quit returns the first match arbitrarily, and the dependency loop later picks up the second match, resulting in both being passed to dnf_install.

Fix

  • sort -V | tail -n 1 instead of -print -quit: deterministically selects the latest release version when multiple RPMs match
  • rm -f before download fallback: cleans up stale RPMs before downloading a new version, preventing accumulation of conflicting release versions

Testing

Regenerated snapshot testdata via make generate-testdata — all Mariner/AzureLinux CustomData snapshots updated.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to prevent Azure Linux v3/Mariner RPM install failures caused by multiple cached release variants of the same package being passed to dnf install (triggering “conflicting requests”), by making cached RPM selection deterministic and cleaning up stale cached RPMs on download fallback.

Changes:

  • Update installRPMPackageFromFile RPM selection to choose the “latest” matching RPM via sort -V | tail -n 1.
  • Remove stale ${packageName}-${desiredVersion}*.rpm files before downloading a fallback RPM version.
  • Regenerate pkg/agent/testdata/*/CustomData snapshot outputs.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
parts/linux/cloud-init/artifacts/mariner/cse_install_mariner.sh Adjust RPM selection logic and cleanup behavior in installRPMPackageFromFile.
pkg/agent/testdata/Marinerv2+DisableUnattendedUpgrades=true/CustomData Regenerated CustomData snapshot.
pkg/agent/testdata/Marinerv2+DisableUnattendedUpgrades=false/CustomData Regenerated CustomData snapshot.
pkg/agent/testdata/MarinerV2+Kata/CustomData Regenerated CustomData snapshot.
pkg/agent/testdata/MarinerV2+CustomCloud/CustomData Regenerated CustomData snapshot.
pkg/agent/testdata/MarinerV2+CustomCloud+USSec/CustomData Regenerated CustomData snapshot.
pkg/agent/testdata/MarinerV2+CustomCloud+USNat/CustomData Regenerated CustomData snapshot.
pkg/agent/testdata/AzureLinuxv2+DisableUnattendedUpgrades=true/CustomData Regenerated CustomData snapshot.
pkg/agent/testdata/AzureLinuxv2+DisableUnattendedUpgrades=false/CustomData Regenerated CustomData snapshot.
pkg/agent/testdata/AzureLinuxV3+Kata/CustomData Regenerated CustomData snapshot.
pkg/agent/testdata/AzureLinuxV2+Kata/CustomData Regenerated CustomData snapshot.
Comments suppressed due to low confidence (1)

parts/linux/cloud-init/artifacts/mariner/cse_install_mariner.sh:449

  • rpmFile selection now deterministically picks the latest matching RPM, but the later dependency-collection loop still appends other cached RPMs that match ${packageName}-${desiredVersion}-*.rpm (including older release variants). If both kubectl-<ver>-1...rpm and kubectl-<ver>-2...rpm exist, rpmArgs will still contain both and dnf_install can still hit "conflicting requests". Consider filtering cached RPMs so only the chosen rpmFile is included for the main package (or proactively deleting older ${rpmPattern}*.rpm matches before building rpmArgs).
    rpmFile=$(find "${downloadDir}" -maxdepth 1 -type f -name "${rpmPattern}*.rpm" 2>/dev/null | sort -V | tail -n 1) || rpmFile=""
    if [ -z "${rpmFile}" ]; then
        if fallbackToKubeBinaryInstall "${packageName}" "${desiredVersion}"; then
            echo "Successfully installed ${packageName} version ${desiredVersion} from binary fallback"
            rm -rf "${downloadDir}"

return 1
fi
echo "Did not find cached rpm file, downloading ${packageName} version ${fullPackageVersion}"
rm -f "${downloadDir}"/${rpmPattern}*.rpm
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm -f "${downloadDir}"/${rpmPattern}*.rpm leaves ${rpmPattern} unquoted, which can trigger ShellCheck warnings (word-splitting) and is also less safe if filenames begin with -. Prefer quoting the variable portion and using -- so only the glob expands (and options can’t be parsed from filenames).

Suggested change
rm -f "${downloadDir}"/${rpmPattern}*.rpm
rm -f -- "${downloadDir}/${rpmPattern}"*.rpm

Copilot uses AI. Check for mistakes.
@awesomenix awesomenix force-pushed the fix/azl3-rpm-conflicting-requests branch from 8a4dfe3 to bd5196d Compare March 3, 2026 22:33
@awesomenix awesomenix force-pushed the fix/azl3-rpm-conflicting-requests branch from bd5196d to f8c939a Compare March 3, 2026 22:37
Copilot AI review requested due to automatic review settings March 3, 2026 22:37
@awesomenix awesomenix force-pushed the fix/azl3-rpm-conflicting-requests branch from f8c939a to 20eb585 Compare March 3, 2026 22:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

@awesomenix awesomenix force-pushed the fix/azl3-rpm-conflicting-requests branch from 20eb585 to 6ec8766 Compare March 3, 2026 23:27
@awesomenix awesomenix force-pushed the fix/azl3-rpm-conflicting-requests branch from 6ec8766 to d4189e2 Compare March 3, 2026 23:29
@awesomenix awesomenix force-pushed the fix/azl3-rpm-conflicting-requests branch from d4189e2 to 153cf25 Compare March 3, 2026 23:33
Copilot AI review requested due to automatic review settings March 3, 2026 23:33
… Linux

   When multiple RPM release versions of the same package coexist in the
   download cache (e.g. kubectl-1.34.3-1.azl3 and kubectl-1.34.3-2.azl3),
   find with -print -quit arbitrarily picks one and can pass both to dnf,
   causing 'conflicting requests' errors.

   - Replace -print -quit with sort -V | tail -n 1 to deterministically
     select the latest release version
   - Add rm -f before download fallback to prevent RPM accumulation

   Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@awesomenix awesomenix force-pushed the fix/azl3-rpm-conflicting-requests branch from 153cf25 to b214c0e Compare March 3, 2026 23:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.

@awesomenix awesomenix enabled auto-merge (squash) March 3, 2026 23:37
@cameronmeissner cameronmeissner disabled auto-merge March 4, 2026 00:20
@cameronmeissner cameronmeissner merged commit f033c04 into main Mar 4, 2026
17 of 27 checks passed
@cameronmeissner cameronmeissner deleted the fix/azl3-rpm-conflicting-requests branch March 4, 2026 00:21
awesomenix added a commit that referenced this pull request Mar 4, 2026
…ile for Azure Linux (#8003) (#8007)

Co-authored-by: Nishchay <awesomenix@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants