Skip to content

Conversation

ctalledo
Copy link
Collaborator

@ctalledo ctalledo commented May 21, 2025

- What I did

  • Updated worker.Platforms() in builder-next worker to use platform MatchComparer when checking for matching platforms (same as we do in buildkit, see here.

  • Added a unit test.

Fixes #50037.

- How to verify it

go test -v ./builder/builder-next/worker/

- A picture of a cute animal (not mandatory but encouraged)

@ctalledo
Copy link
Collaborator Author

Thanks @thaJeztah for the review and comments, I've responded to all and updated the code. PTAL when you get a chance.

@ctalledo ctalledo requested a review from thaJeztah May 21, 2025 19:15
@ctalledo
Copy link
Collaborator Author

Note: CI failures are unrelated to this PR.

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

left two suggestions; no blockers, but let me know what you think.

Also /cc @tonistiigi to review if this is what you had in mind

@ctalledo ctalledo force-pushed the fix-for-50037 branch 2 times, most recently from 7496d47 to c075f20 Compare May 21, 2025 22:13
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!


// platformsFn looks up supported platforms on the host,
// and is overridden in unit-tests.
platformsFn func(noCache bool) []ocispec.Platform
Copy link
Member

Choose a reason for hiding this comment

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

Don't add this to the worker. If you need a function for the unit tests then create a separate function with configurable parameters for it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure I follow the suggestion; I need a way to mock archutils.SupportedPlatforms() when called within Worker.Platforms(). Not sure what alternative you are suggesting to the approach I took.

Copy link
Member

Choose a reason for hiding this comment

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

Worker, or Worker.Platforms() doesn't support providing custom values for set of defined and supported platforms. If you want to test combining these arrays with these conditions then you would need to define a new function like allPlatforms(defined, supported []ocispec.Platforms) []ocispec.Platforms, write unit test for that and make worker.Platforms() call it internally.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK done, thanks for the suggestion (see mergePlatforms()).

@ctalledo ctalledo requested a review from tonistiigi May 22, 2025 17:25
@ctalledo
Copy link
Collaborator Author

Note: CI passes (test failure is unrelated to this change).

Use platform MatchComparer when checking for matching platforms.

Also, add unit test to ensure the merging of defined and host-supported
platforms works correctly.

Signed-off-by: Cesar Talledo <cesar.talledo@docker.com>
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

@thaJeztah thaJeztah merged commit 7a0bf74 into moby:master May 29, 2025
160 checks passed
@thaJeztah thaJeztah added this to the 28.2.2 milestone May 29, 2025
@ctalledo ctalledo deleted the fix-for-50037 branch May 29, 2025 15:39
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.

Update worker.Platforms() in builder/builder-next/worker/worker.go
3 participants