Skip to content

stage_executor: check platform of cache candidates#6269

Merged
openshift-merge-bot[bot] merged 1 commit intocontainers:mainfrom
flouthoc:cache-canidates
Jul 11, 2025
Merged

stage_executor: check platform of cache candidates#6269
openshift-merge-bot[bot] merged 1 commit intocontainers:mainfrom
flouthoc:cache-canidates

Conversation

@flouthoc
Copy link
Collaborator

@flouthoc flouthoc commented Jul 8, 2025

When building images for manifest list using --platform same image is used for multiple platform if base is scratch , following PR adds a check to always verify platform of cache with target.

Closes: containers/podman#18723

What type of PR is this?

/kind api-change
/kind bug
/kind cleanup
/kind deprecation
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake
/kind other

What this PR does / why we need it:

How to verify it

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Build makes sure that platform considered correctly before using potential image as cache candidate

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 8, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flouthoc

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

Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

This looks plausible from a 1-minute skim but I’m not very familiar with this subpackage.

// Check if the cached image's platform matches the current build's target platform.
// This is critical for multi-platform builds to ensure each platform gets its own
// properly built image instead of incorrectly reusing cached images from other platforms.
imageRef, err := is.Transport.ParseStoreReference(s.executor.store, "@"+image.ID)
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking: NewStoreReference(store, nil, image.ID)

@flouthoc flouthoc requested a review from nalind July 8, 2025 18:49
@TomSweeneyRedHat TomSweeneyRedHat changed the title stage_executor: check platform of cache canidates stage_executor: check platform of cache candidates Jul 8, 2025
@TomSweeneyRedHat
Copy link
Member

LGTM
but tests aren't happy

@TomSweeneyRedHat
Copy link
Member

@flouthoc the tests may work if you rebase and pick up #6271

Copy link
Member

@nalind nalind left a comment

Choose a reason for hiding this comment

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

This should probably have getImageTypeAndHistoryAndDiffIDs() cache the config fields along with the things it already caches, and return them instead of doing a fresh lookup and parse here.

@nalind
Copy link
Member

nalind commented Jul 10, 2025

Is this meant to catch cases like

buildah build --layers --platform linux/ppc64le -f ./tests/bud/from-scratch/Containerfile2 ./tests/bud/from-scratch/
buildah build --layers -f ./tests/bud/from-scratch/Containerfile2 ./tests/bud/from-scratch/

@flouthoc flouthoc requested a review from nalind July 10, 2025 18:50
@TomSweeneyRedHat
Copy link
Member

LGTM
once @nalind 's question is answered.

flouthoc added a commit to flouthoc/buildah that referenced this pull request Jul 10, 2025
If `arch` and `os` are not set, parse and use default values inorder to
prevent matching against incorrect cache candidates.

Addresses: containers#6269 (comment)

Signed-off-by: flouthoc <[email protected]>
@flouthoc
Copy link
Collaborator Author

Is this meant to catch cases like

buildah build --layers --platform linux/ppc64le -f ./tests/bud/from-scratch/Containerfile2 ./tests/bud/from-scratch/
buildah build --layers -f ./tests/bud/from-scratch/Containerfile2 ./tests/bud/from-scratch/

@nalind Added a new commit to address this.

flouthoc added a commit to flouthoc/buildah that referenced this pull request Jul 10, 2025
If `arch` and `os` are not set, parse and use default values inorder to
prevent matching against incorrect cache candidates.

Addresses: containers#6269 (comment)

Signed-off-by: flouthoc <[email protected]>
flouthoc added a commit to flouthoc/buildah that referenced this pull request Jul 10, 2025
If `arch` and `os` are not set, parse and use default values inorder to
prevent matching against incorrect cache candidates.

Addresses: containers#6269 (comment)

Signed-off-by: flouthoc <[email protected]>
@flouthoc flouthoc requested a review from nalind July 10, 2025 22:34
@packit-as-a-service
Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

@nalind
Copy link
Member

nalind commented Jul 11, 2025

Squash the commits together, fix the typo in the commit title, then it'll LGTM.

@flouthoc
Copy link
Collaborator Author

@nalind Done.

@nalind
Copy link
Member

nalind commented Jul 11, 2025

LGTM

@rhatdan
Copy link
Member

rhatdan commented Jul 11, 2025

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jul 11, 2025
When building images for `manifest` list using `--platform` same image
is used for multiple platform if base is `scratch` , following PR adds a
check to always verify `platform` of `cache` with `target`.

Closes: containers/podman#18723

Signed-off-by: flouthoc <[email protected]>
@openshift-ci openshift-ci bot removed the lgtm label Jul 11, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 11, 2025

New changes are detected. LGTM label has been removed.

@flouthoc
Copy link
Collaborator Author

Rebased to remove conflicts.

@flouthoc flouthoc added the lgtm label Jul 11, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit 8403fd6 into containers:main Jul 11, 2025
28 of 37 checks passed
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators Oct 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Manifest generation on building multi-platform from scratch

5 participants