Skip to content

Conversation

@zuoxuesong-worker
Copy link
Contributor

What type of PR is this?

/kind feature

What this PR does / why we need it:

when make offline package , we maybe only need amd64 and arm64 image
but some image has other arch which we dont need
change pull func , we can pull image with arch we want

Which issue(s) this PR fixes:

Fixes #

Special notes for reviewers:

pull image with multi arch

Does this PR introduced a user-facing change?

pull image with multi arch

Additional documentation, usage docs, etc.:


@kubesphere-prow
Copy link

This PR has multiple commits, and the default merge method is: squash.
You can request commits to be merged using the label: tide/merge-method-merge

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@kubesphere-prow kubesphere-prow bot added release-note kind/feature Categorizes issue or PR as related to a new feature. labels Dec 4, 2025
@kubesphere-prow
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: zuoxuesong-worker

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubesphere-prow kubesphere-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 4, 2025
@gemini-code-assist
Copy link

Summary of Changes

Hello @zuoxuesong-worker, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly upgrades the image pulling functionality by introducing support for multi-architecture image selection. Previously, the system might pull all available architectures for an image, which is inefficient, especially when creating offline packages for specific environments. The new implementation allows users to specify desired architectures, ensuring that only the necessary image variants are downloaded and stored, leading to more streamlined and efficient image management.

Highlights

  • Multi-Architecture Image Pulling: Introduced the capability to pull container images for specific architectures, addressing the need to avoid downloading unnecessary architectures during offline package creation.
  • Flexible Platform Selection: The image pulling mechanism now accepts a list of desired platforms (e.g., "amd64", "arm64"), allowing for precise control over which image variants are downloaded.
  • Enhanced Image Manifest Handling: New internal logic has been implemented to parse OCI image indexes, filter individual manifests based on the specified architectures, and reconstruct a new image index containing only the relevant platform-specific images.
  • Configuration Update: The images.yaml configuration file has been updated to include a platform field, enabling users to define target architectures directly in their image pull configurations.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@kubesphere-prow kubesphere-prow bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 4, 2025
@zuoxuesong-worker zuoxuesong-worker force-pushed the feat/pull-image-with-multi-arch branch from dcc4bd6 to 78efccb Compare December 4, 2025 05:56
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a feature to pull specific architectures of a multi-arch container image. The implementation involves manually fetching the image index, filtering manifests based on the desired platforms, and then reconstructing a new index with only the selected architectures.

The overall approach is sound, but I have identified a few areas for improvement regarding correctness, robustness, and code maintainability. My main concerns are a potential silent failure if no matching architectures are found, and an imprecise architecture matching logic that could lead to bugs. I've also suggested replacing some magic strings with predefined constants to improve readability. Please see my detailed comments below.

Comment on lines 217 to 234
// some arm architecture is arm64/v7 or arm68/v8 , support all of then
for _, arch := range platform {
if strings.Contains(manifest.Platform.Architecture, arch) {
manifest.SourceRepo = src
filteredManifests = append(filteredManifests, manifest)
break
}
}

Choose a reason for hiding this comment

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

high

The use of strings.Contains for matching architectures is too broad and can lead to incorrect behavior. For example, if a user requests the arm architecture, this will also match arm64, which is likely not the intended behavior. A direct equality check (==) should be used for a precise match.

Additionally, the comment on line 217 is confusing and contains typos (arm68, then). The arm64/v7 combination is also not standard. I've suggested a replacement with a clearer comment and the corrected logic.

Suggested change
// some arm architecture is arm64/v7 or arm68/v8 , support all of then
for _, arch := range platform {
if strings.Contains(manifest.Platform.Architecture, arch) {
manifest.SourceRepo = src
filteredManifests = append(filteredManifests, manifest)
break
}
}
// Match architecture precisely.
for _, arch := range platform {
if manifest.Platform.Architecture == arch {
manifest.SourceRepo = src
filteredManifests = append(filteredManifests, manifest)
break
}
}

Comment on lines 227 to 238
if len(filteredManifests) == 0 {
return nil
}

Choose a reason for hiding this comment

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

high

When len(filteredManifests) is 0, it means no images were found for the specified architectures. The function currently returns nil, indicating success, which can be misleading as no images were actually pulled. This should return an error to inform the user that the requested architectures were not found for the given image.

Suggested change
if len(filteredManifests) == 0 {
return nil
}
if len(filteredManifests) == 0 {
return errors.Errorf("no manifests found for image %q and platforms %v", img, platform)
}

Comment on lines +277 to +287
if desc.MediaType == imagev1.MediaTypeImageIndex ||
desc.MediaType == "application/vnd.docker.distribution.manifest.list.v2+json" {

Choose a reason for hiding this comment

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

medium

The string literal "application/vnd.docker.distribution.manifest.list.v2+json" is used here. To improve code readability and maintainability, it's better to use the predefined constant images.MediaTypeDockerSchema2ManifestList from the github.com/containerd/containerd/images package, which is already imported.

Suggested change
if desc.MediaType == imagev1.MediaTypeImageIndex ||
desc.MediaType == "application/vnd.docker.distribution.manifest.list.v2+json" {
if desc.MediaType == imagev1.MediaTypeImageIndex ||
desc.MediaType == images.MediaTypeDockerSchema2ManifestList {

Comment on lines +290 to +300
if manifestDesc.MediaType != imagev1.MediaTypeImageManifest &&
manifestDesc.MediaType != "application/vnd.docker.distribution.manifest.v2+json" {

Choose a reason for hiding this comment

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

medium

The string literal "application/vnd.docker.distribution.manifest.v2+json" is used here. To improve code readability and maintainability, it's better to use the predefined constant images.MediaTypeDockerSchema2Manifest from the github.com/containerd/containerd/images package, which is already imported.

Suggested change
if manifestDesc.MediaType != imagev1.MediaTypeImageManifest &&
manifestDesc.MediaType != "application/vnd.docker.distribution.manifest.v2+json" {
if manifestDesc.MediaType != imagev1.MediaTypeImageManifest &&
manifestDesc.MediaType != images.MediaTypeDockerSchema2Manifest {

Comment on lines +302 to +312
} else if desc.MediaType == imagev1.MediaTypeImageManifest ||
desc.MediaType == "application/vnd.docker.distribution.manifest.v2+json" {

Choose a reason for hiding this comment

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

medium

The string literal "application/vnd.docker.distribution.manifest.v2+json" is used here. To improve code readability and maintainability, it's better to use the predefined constant images.MediaTypeDockerSchema2Manifest from the github.com/containerd/containerd/images package, which is already imported.

Suggested change
} else if desc.MediaType == imagev1.MediaTypeImageManifest ||
desc.MediaType == "application/vnd.docker.distribution.manifest.v2+json" {
} else if desc.MediaType == imagev1.MediaTypeImageManifest ||
desc.MediaType == images.MediaTypeDockerSchema2Manifest {

@zuoxuesong-worker zuoxuesong-worker force-pushed the feat/pull-image-with-multi-arch branch 2 times, most recently from 6521082 to 931209f Compare December 4, 2025 06:11
…ine them to one image

Signed-off-by: [email protected] <[email protected]>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: [email protected] <[email protected]>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: [email protected] <[email protected]>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: [email protected] <[email protected]>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: [email protected] <[email protected]>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: [email protected] <[email protected]>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: [email protected] <[email protected]>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: [email protected] <[email protected]>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: [email protected] <[email protected]>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: [email protected] <[email protected]>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: [email protected] <[email protected]>
@zuoxuesong-worker zuoxuesong-worker force-pushed the feat/pull-image-with-multi-arch branch from 931209f to 744fd6f Compare December 9, 2025 02:33
# Conflicts:
#	docs/zh/modules/image.md
#	pkg/modules/image.go
@zuoxuesong-worker zuoxuesong-worker force-pushed the feat/pull-image-with-multi-arch branch 2 times, most recently from 7093fae to 1248e74 Compare December 9, 2025 09:30
…ine them to one image

Signed-off-by: [email protected] <[email protected]>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: [email protected] <[email protected]>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: [email protected] <[email protected]>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: [email protected] <[email protected]>
@zuoxuesong-worker zuoxuesong-worker force-pushed the feat/pull-image-with-multi-arch branch from 1248e74 to e3cd061 Compare December 10, 2025 02:54
@zuoxuesong-worker zuoxuesong-worker force-pushed the feat/pull-image-with-multi-arch branch from 438237b to 2e7784b Compare December 22, 2025 07:01
…ine them to one image

Signed-off-by: [email protected] <[email protected]>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: [email protected] <[email protected]>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: [email protected] <[email protected]>
@zuoxuesong-worker zuoxuesong-worker force-pushed the feat/pull-image-with-multi-arch branch from 2e7784b to 17b2d91 Compare December 22, 2025 09:18
@sonarqubecloud
Copy link

@redscholar
Copy link
Contributor

/lgtm

@kubesphere-prow kubesphere-prow bot added the lgtm Indicates that a PR is ready to be merged. label Dec 23, 2025
@kubesphere-prow
Copy link

LGTM label has been added.

DetailsGit tree hash: d63e737abf03f912109db600fe45a931e167bf83

@kubesphere-prow kubesphere-prow bot merged commit 238eb2b into kubesphere:main Dec 23, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants