fix: deduplicate RPM selection in installRPMPackageFromFile for Azure Linux#8003
Conversation
There was a problem hiding this comment.
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
installRPMPackageFromFileRPM selection to choose the “latest” matching RPM viasort -V | tail -n 1. - Remove stale
${packageName}-${desiredVersion}*.rpmfiles before downloading a fallback RPM version. - Regenerate
pkg/agent/testdata/*/CustomDatasnapshot 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
rpmFileselection 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 bothkubectl-<ver>-1...rpmandkubectl-<ver>-2...rpmexist,rpmArgswill still contain both anddnf_installcan still hit "conflicting requests". Consider filtering cached RPMs so only the chosenrpmFileis included for the main package (or proactively deleting older${rpmPattern}*.rpmmatches before buildingrpmArgs).
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 |
There was a problem hiding this comment.
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).
| rm -f "${downloadDir}"/${rpmPattern}*.rpm | |
| rm -f -- "${downloadDir}/${rpmPattern}"*.rpm |
8a4dfe3 to
bd5196d
Compare
bd5196d to
f8c939a
Compare
f8c939a to
20eb585
Compare
parts/linux/cloud-init/artifacts/mariner/cse_install_mariner.sh
Outdated
Show resolved
Hide resolved
20eb585 to
6ec8766
Compare
6ec8766 to
d4189e2
Compare
d4189e2 to
153cf25
Compare
… 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>
153cf25 to
b214c0e
Compare
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.rpmandkubectl-1.34.3-2.azl3.x86_64.rpm), both files were passed todnf install, causing "conflicting requests" errors because both RPMs provide the same package at the same version.The root cause is that
find ... -print -quitreturns the first match arbitrarily, and the dependency loop later picks up the second match, resulting in both being passed todnf_install.Fix
sort -V | tail -n 1instead of-print -quit: deterministically selects the latest release version when multiple RPMs matchrm -fbefore download fallback: cleans up stale RPMs before downloading a new version, preventing accumulation of conflicting release versionsTesting
Regenerated snapshot testdata via
make generate-testdata— all Mariner/AzureLinux CustomData snapshots updated.