Skip to content

fix: filter apt list by CPU architecture to prevent cross-arch kubelet install failures#8639

Merged
djsly merged 1 commit into
mainfrom
djsly/djsly-38257849
Jun 4, 2026
Merged

fix: filter apt list by CPU architecture to prevent cross-arch kubelet install failures#8639
djsly merged 1 commit into
mainfrom
djsly/djsly-38257849

Conversation

@djsly
Copy link
Copy Markdown
Collaborator

@djsly djsly commented Jun 4, 2026

Summary

Fixes a bug where installPkgWithAptGet in Ubuntu CSE picks arm64-only package versions on amd64 nodes, causing kubelet download failures (404).

Root Cause

apt list --all-versions returns entries for all architectures:

kubelet/noble 1.34.0-ubuntu24.04u6 arm64
kubelet/noble 1.34.0-ubuntu24.04u5 amd64
kubelet/noble 1.34.0-ubuntu24.04u5 arm64

The existing grep pipeline only filtered by k8s version (e.g., 1.34.0), so sort -V | tail -n 1 could select a version that only exists for arm64 (u6). When an amd64 node then calls apt-get download kubelet=1.34.0-ubuntu24.04u6, it fails with 404.

Fix

Added grep "$(getCPUArch)" to the pipeline to filter apt list output to only the current node's architecture before selecting the latest version:

# Before (broken)
fullPackageVersion=$(apt list "${packageName}" --all-versions | grep "${packageVersion}" | awk '{print $2}' | sort -V | tail -n 1)

# After (fixed)
fullPackageVersion=$(apt list "${packageName}" --all-versions | grep "${packageVersion}" | grep "$(getCPUArch)" | awk '{print $2}' | sort -V | tail -n 1)

getCPUArch is already defined in cse_helpers.sh and returns "amd64" or "arm64".

Impact

Users reported kubelet download failures on Ubuntu 24.04 amd64 nodes for k8s 1.34.0 and 1.34.1:

  • kubelet_1.34.0-ubuntu24.04u6 — arm64 only, no amd64
  • kubelet_1.34.1-ubuntu24.04u5 — arm64 only, no amd64

Testing

  • GENERATE_TEST_DATA=true go test ./pkg/agent/... — all pass
  • Snapshot test data unchanged (shell script change, not Go template)

AB#38257849

Copy link
Copy Markdown
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@djsly djsly force-pushed the djsly/djsly-38257849 branch from 641dca5 to 3c2f7a2 Compare June 4, 2026 17:51
…t install failures

apt list --all-versions returns package entries for all architectures. Without
filtering by the node CPU architecture, sort -V | tail -n 1 may select a
package version that only exists for a different architecture (e.g., arm64-only
u6 on an amd64 node), causing apt-get download to fail with 404.

Add grep "$(getCPUArch)" to the pipeline to ensure only packages matching the
current node architecture are considered when selecting the latest version.

AB#38257849

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 4, 2026 18:23
@djsly djsly force-pushed the djsly/djsly-38257849 branch from 3c2f7a2 to ed1ded1 Compare June 4, 2026 18:23
Copy link
Copy Markdown
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot stopped reviewing on behalf of djsly due to an error June 4, 2026 19:24
@djsly djsly merged commit 452494e into main Jun 4, 2026
33 of 34 checks passed
@djsly djsly deleted the djsly/djsly-38257849 branch June 4, 2026 20:02
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.

3 participants