Skip to content

Conversation

@shfc
Copy link

@shfc shfc commented Nov 23, 2025

Fixes: #9161
Related: N/A
Merge before/after: N/A

Description

Problem:
Skaffold fails when building platform-specific containers (Windows, ARM) with errors like:
no child with platform linux/amd64 in index

Root cause:
Skaffold retrieves base images using the default platform linux/amd64 instead of the user-specified target platform.

Solution
Thread the platform parameter through the dependency resolution chain:

  • Extract platform from build metadata during cache hash computation
  • Pass platform to all dependency resolution functions
  • Use platform when retrieving remote image configurations

Platform selection logic:

  • Single-platform builds: use specified platform
  • Multi-platform builds: use first platform (dependencies typically platform-independent)
  • No platform specified: use empty platform (backward compatible)

@shfc shfc requested a review from a team as a code owner November 23, 2025 13:41
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @shfc, 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 resolves a long-standing problem in Skaffold that caused failures when attempting to build containers for non-default or multi-platform architectures. Previously, Skaffold would incorrectly default to linux/amd64 when resolving base image dependencies, leading to build errors. The changes introduce explicit platform awareness throughout the dependency resolution pipeline, ensuring that the correct target platform is used for fetching image configurations and calculating build cache hashes. This enhancement significantly improves Skaffold's compatibility with diverse build environments and multi-architecture container images.

Highlights

  • Platform-Aware Dependency Resolution: Skaffold's dependency resolution process now correctly incorporates the target platform, addressing issues where builds for specific architectures (e.g., ARM, Windows) failed due to incorrect base image retrieval.
  • Platform Parameter Propagation: The platform parameter is consistently threaded through various functions involved in dependency listing, cache hash computation, and remote image configuration retrieval.
  • Intelligent Platform Selection: Logic has been implemented to determine the appropriate platform for dependency resolution: using the specified platform for single-platform builds, the first platform for multi-platform builds (assuming platform-independent dependencies), and an empty platform for backward compatibility.
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.

Copy link
Contributor

@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 is a good step towards improving multi-platform build support in Skaffold by threading the platform parameter through the dependency resolution chain. The changes are quite extensive and touch many files, which is expected for such a feature. However, I've identified a few areas where the platform information is either hardcoded to an empty value or not propagated correctly, which could undermine the fix for certain build types like local Docker and GCB. I've provided specific comments and suggestions to address these issues. Addressing these points will make the multi-platform support more robust.

// only the COPY/ADD commands from the last image are syncable
fts, err := ReadCopyCmdsFromDockerfile(ctx, true, absDockerfilePath, workspace, buildArgs, cfg)
// Use empty platform as this is for file syncing, not platform-specific image retrieval
fts, err := ReadCopyCmdsFromDockerfile(ctx, true, absDockerfilePath, workspace, buildArgs, cfg, v1.Platform{})
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

An empty platform is passed to ReadCopyCmdsFromDockerfile. The comment states this is for file syncing and not platform-specific, but if a base image has platform-dependent ONBUILD instructions, this could lead to an incorrect sync map. The SyncMap function is called from contexts where platform information is not available, which might be a limitation, but it's worth noting as a potential issue for complex multi-platform scenarios with file sync.

…ate platform in GCB and context creation

- Update LocalDaemon.Build interface signature to include platform parameter
- Extract platform from platform.Matcher in GCB cloud_build.go for dependency resolution
- Thread platform parameter through CreateDockerTarContext call chain
- Fix test mocks and calls to pass platform parameter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Skaffold tried to pull image for wrong plaform

1 participant