Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of the multi-platform support for builders and buildpack packages RFC 0128 #2086

Merged

Conversation

jjbustamante
Copy link
Member

@jjbustamante jjbustamante commented Mar 1, 2024

Summary

The purpose of this PR is to implement the RFC 0128.

It adds the capability to the pack buildpack package and pack builder create to generate multi-platform OCI images and create an image index to combine them.

A draft version of this PR was demo during KubeCon EU 24. See the recording here

Output

Before

  • We were not able to create multi-platform buildpacks and builders

After

  • Follow the RFC documentation to specify Targets entries in the buildpack.toml or package.toml files.

Check the document mentioned above, it has a detailed output

Documentation

  • Should this change be documented?
    • Yes, see
    • No

Related

Resolves #1459
Resolves #2079

@github-actions github-actions bot added type/enhancement Issue that requests a new feature or improvement. type/chore Issue that requests non-user facing changes. labels Mar 1, 2024
@github-actions github-actions bot added this to the 0.34.0 milestone Mar 1, 2024
Copy link

codecov bot commented Mar 1, 2024

Codecov Report

Attention: Patch coverage is 21.31336% with 683 lines in your changes are missing coverage. Please review.

Project coverage is 75.98%. Comparing base (1e41857) to head (c7b1521).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2086      +/-   ##
==========================================
- Coverage   79.69%   75.98%   -3.71%     
==========================================
  Files         176      192      +16     
  Lines       13254    14038     +784     
==========================================
+ Hits        10562    10665     +103     
- Misses       2022     2676     +654     
- Partials      670      697      +27     
Flag Coverage Δ
os_linux 74.93% <21.32%> (-3.69%) ⬇️
os_macos 72.72% <20.28%> (-3.58%) ⬇️
os_windows 75.40% <21.32%> (-3.68%) ⬇️
unit 75.98% <21.32%> (-3.71%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@jjbustamante jjbustamante modified the milestones: 0.34.0, 0.35.0 Mar 8, 2024
@anthonydahanne
Copy link
Contributor

Hello 👋
We have been testing the latest version

./pack --version
0.0.0+git-3cb6546.build-5619

from
https://github.com/buildpacks/pack/actions/runs/8118576298

We had success running, from the ~/buildpack directory, using:

pack buildpack package anthonydahanne/syft:dual6 --publish
Successfully published package anthonydahanne/syft:dual6 and saved to registry

with a layout similar to this:

tree ~/buildpack
/home/ubuntu/buildpack
├── LICENSE
├── NOTICE
├── README.md
├── buildpack.toml
└── linux
    ├── amd64
    │   └── bin
    │       ├── build -> main
    │       ├── detect -> main
    │       └── main
    └── arm64
        └── bin
            ├── build -> main
            ├── detect -> main
            └── main

5 directories, 10 files

and we successfully obtained a multi arch image:

docker manifest inspect anthonydahanne/syft:dual6
{
   "schemaVersion": 2,
   "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
   "manifests": [
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 428,
         "digest": "sha256:91f6b87823cfb8b0df8d415da9b40774790f655bc7c576e4b2d4abde8cf0816a",
         "platform": {
            "architecture": "amd64",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 428,
         "digest": "sha256:01da98c691e2912e8f32c8b28c93ec26968d6c5857fb4e19313d718d3156f121",
         "platform": {
            "architecture": "arm64",
            "os": "linux"
         }
      }
   ]
}

Yay 🎉

But then, we tried running it from elsewhere, using such a package.toml:

cat ~/package.toml
[buildpack]
uri = "/home/ubuntu/buildpack"
./pack buildpack package anthonydahanne/syft:dual5 --config "${HOME}"/package.toml --publish
Warning: A new '--target' flag is available to set the platform for the buildpack package, using 'linux' as default
Successfully published package anthonydahanne/syft:dual5 and saved to registry

and this did not produce an expected dual arch image:

docker manifest inspect anthonydahanne/syft:dual5
{
	"schemaVersion": 2,
	"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
	"config": {
		"mediaType": "application/vnd.docker.container.image.v1+json",
		"size": 1172,
		"digest": "sha256:0d68e7e4493ba8637d296368acd932332611dd9633bf977c77f8f5339982e0aa"
	},
	"layers": [
		{
			"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
			"size": 5662387,
			"digest": "sha256:0f3a885b04767878fefc27a532e71911888fbba96708b632c0a5f95ca9a2c1a8"
		}
	]
}

Is it either a bug or do we do something wrong?
Thank you 🙏

@jjbustamante
Copy link
Member Author

Hi @anthonydahanne

Is it either a bug or do we do something wrong?

Yeah, it is a bug, I noticed that when preparing my script for the KubeCon demo, I haven't took a look yet, sorry! keep testing it running from the buildpack/builder folder

@sophiewigmore
Copy link

We're just going to document all of our issues as we encounter them. Using the same pack version as @anthonydahanne's comment above, we are running into a duplicate manifest issue.

  1. We successfully run pack buildpack package <image>:<tag> --publish from the /buildpack directory per your instruction
  2. We re-run pack buildpack package <image>:<tag> --publish, as we will likely do in our CI pipelines everntually to update the latest tag for an image.
  3. The image manifest contains duplicate manifest entries, instead of being updated:
docker manifest inspect <image>:<tag>
{
   "schemaVersion": 2,
   "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
   "manifests": [
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 428,
         "digest": "sha256:63fa2e8bbdaead0b5e9f38f968eeb0c1beebdb7c94b62729ee7132da078ec17c",
         "platform": {
            "architecture": "amd64",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 428,
         "digest": "sha256:ac56bf570204550814118621a098a5182ba732919454869711a9b4c51abf3e28",
         "platform": {
            "architecture": "arm64",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 428,
         "digest": "sha256:63fa2e8bbdaead0b5e9f38f968eeb0c1beebdb7c94b62729ee7132da078ec17c",
         "platform": {
            "architecture": "amd64",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 428,
         "digest": "sha256:ac56bf570204550814118621a098a5182ba732919454869711a9b4c51abf3e28",
         "platform": {
            "architecture": "arm64",
            "os": "linux"
         }
      }
   ]
}

We'd expect the manifest list to only contain the latest entries

@jjbustamante
Copy link
Member Author

Thank you @sophiewigmore ! Yes I noticed the duplication too! that's part of the manifest code Husni was working on.

@anthonydahanne
Copy link
Contributor

hello @jjbustamante ! any updates since Kubecon?
on the Paketo sides of things, we use the exp. pack CLI from a good number of our buildpacks workflows to support dual arch!
Please let us know! Thanks!

@jjbustamante
Copy link
Member Author

hello @jjbustamante ! any updates since Kubecon? on the Paketo sides of things, we use the exp. pack CLI from a good number of our buildpacks workflows to support dual arch! Please let us know! Thanks!

Hi @anthonydahanne, some updates:

  • I am working on trying to merge the branch from Husni and Sai with the implementation of the manifest commands RFC, We need these changes first because that's the code that is handling the Image Index creation logic.
  • I was off last Thursday/Friday but the multi-plaftorm RFC is on voting state, I think we should be merging that one this week.
  • Once the manifest command logic is merged, I still need to fix the current bugs and polish a little bit this logic to un-draft it, I hope at the end of this week or next one I can have more updates on this!

Copy link
Member

@natalieparellano natalieparellano left a comment

Choose a reason for hiding this comment

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

Still going through it, but leaving a few comments in the meantime :)

buildpackage/config_reader.go Show resolved Hide resolved
pkg/image/fetcher.go Outdated Show resolved Hide resolved
pkg/image/fetcher.go Outdated Show resolved Hide resolved
pkg/image/fetcher.go Outdated Show resolved Hide resolved
pkg/dist/buildmodule.go Outdated Show resolved Hide resolved
pkg/dist/buildmodule.go Show resolved Hide resolved
pkg/dist/buildmodule.go Outdated Show resolved Hide resolved
pkg/client/client.go Outdated Show resolved Hide resolved
@jjbustamante jjbustamante force-pushed the jjbustamante/poc-multiarch-rfc branch from c7b1521 to 9c8a2ee Compare May 6, 2024 15:31
Copy link
Member

@natalieparellano natalieparellano left a comment

Choose a reason for hiding this comment

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

@jjbustamante alrighty I've finally looked through all the files. I left a few comments. It mostly looks sensible, though we'll definitely want more tests and probably an acceptance test or two. LMK if I can be of any help at all.

internal/commands/buildpack_package.go Outdated Show resolved Hide resolved
internal/commands/buildpack_package.go Outdated Show resolved Hide resolved
internal/commands/buildpack_package.go Outdated Show resolved Hide resolved
internal/commands/buildpack_package.go Outdated Show resolved Hide resolved
internal/commands/buildpack_package.go Outdated Show resolved Hide resolved
pkg/buildpack/multi_architecture_helper.go Outdated Show resolved Hide resolved
pkg/buildpack/multi_architecture_helper.go Outdated Show resolved Hide resolved
pkg/buildpack/multi_architecture_helper.go Outdated Show resolved Hide resolved
pkg/buildpack/multi_architecture_helper.go Outdated Show resolved Hide resolved
pkg/buildpack/multi_architecture_helper.go Outdated Show resolved Hide resolved
@jjbustamante jjbustamante force-pushed the jjbustamante/poc-multiarch-rfc branch 4 times, most recently from 25e37f4 to cb4b368 Compare May 8, 2024 18:28
@jjbustamante jjbustamante marked this pull request as ready for review May 8, 2024 18:31
@jjbustamante jjbustamante requested review from a team as code owners May 8, 2024 18:31
@jjbustamante jjbustamante changed the title Draft implementation of the multi-architecture RFC Implementation of the multi-platform support for builders and buildpack packages RFC 0128 May 8, 2024
…fecycle

Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
@jjbustamante jjbustamante force-pushed the jjbustamante/poc-multiarch-rfc branch from cfdcaf6 to 6fa0cbc Compare May 21, 2024 16:30
@jjbustamante jjbustamante force-pushed the jjbustamante/poc-multiarch-rfc branch from 6fa0cbc to dad414b Compare May 21, 2024 16:47
pkg/client/create_builder.go Outdated Show resolved Hide resolved
pkg/client/create_builder.go Outdated Show resolved Hide resolved
internal/builder/lifecycle.go Show resolved Hide resolved
internal/commands/buildpack_package.go Show resolved Hide resolved
pkg/buildpack/multi_architecture_helper.go Outdated Show resolved Hide resolved
…rwin

Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
@jjbustamante jjbustamante force-pushed the jjbustamante/poc-multiarch-rfc branch from 7cca91b to 68d1efa Compare May 21, 2024 20:59
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
@jjbustamante jjbustamante force-pushed the jjbustamante/poc-multiarch-rfc branch from 166c3d8 to 0ca0429 Compare May 22, 2024 17:22
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
@jjbustamante jjbustamante force-pushed the jjbustamante/poc-multiarch-rfc branch from 0ca0429 to 03a0d8f Compare May 22, 2024 17:51
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
@jjbustamante jjbustamante force-pushed the jjbustamante/poc-multiarch-rfc branch from 082c69e to ae8e20b Compare May 22, 2024 18:20
Copy link
Member

@natalieparellano natalieparellano left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks for all of your hard work @jjbustamante ❤️

@natalieparellano natalieparellano merged commit 7306444 into buildpacks:main May 22, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/chore Issue that requests non-user facing changes. type/enhancement Issue that requests a new feature or improvement.
Projects
None yet
5 participants