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

Make solving multi-architecture aware #1180

Merged
merged 2 commits into from
Jun 25, 2024

Conversation

jonjohnsonjr
Copy link
Contributor

When building an image with multiple architectures, we now disqualify any packages that aren't available on every architecture.

An example given wolfi trying to solve for trivy=0.36.1-r2, which was only built for arm64, probably because there was a bug in the build that was fixed in a subsequent epoch:

for arch "arm64": installing apk packages: error getting package dependencies: solving "trivy=0.36.1-r2" constraint:
...
trivy-0.36.1-r2.apk disqualified because package "trivy-0.36.1-r2.apk" not available for arch "amd64"

When building an image with multiple architectures, we now disqualify
any packages that aren't available on every architecture.

An example given wolfi trying to solve for `trivy=0.36.1-r2`, which was
only built for arm64, probably because there was a bug in the build that
was fixed in a subsequent epoch:

  for arch "arm64": installing apk packages:
  error getting package dependencies:
  solving "trivy=0.36.1-r2" constraint:
  ...
  trivy-0.36.1-r2.apk disqualified because package "trivy-0.36.1-r2.apk"
    not available for arch "amd64"

Signed-off-by: Jon Johnson <[email protected]>
@jonjohnsonjr jonjohnsonjr merged commit bc6fa0a into chainguard-dev:main Jun 25, 2024
20 checks passed
jonjohnsonjr added a commit to jonjohnsonjr/apko that referenced this pull request Jul 10, 2024
In the terraform module, we call BuildPackageList for each arch:
https://github.com/chainguard-dev/terraform-provider-apko/blob/812478b999411c183e87fefb9a9ece9fe7e8f2c1/internal/provider/config_data_source.go#L239

And then use that package list to actually build the image, so we
separate the solving from the building.

This bypasses chainguard-dev#1180 which
does this multi-arch constraining through a different entrypoint.

This adds another method to the multi-arch stuff that we can opt into
for just the solve part.

Signed-off-by: Jon Johnson <[email protected]>
jonjohnsonjr added a commit to jonjohnsonjr/apko that referenced this pull request Jul 10, 2024
In the terraform module, we call BuildPackageList for each arch:
https://github.com/chainguard-dev/terraform-provider-apko/blob/812478b999411c183e87fefb9a9ece9fe7e8f2c1/internal/provider/config_data_source.go#L239

And then use that package list to actually build the image, so we
separate the solving from the building.

This bypasses chainguard-dev#1180 which
does this multi-arch constraining through a different entrypoint.

This adds another method to the multi-arch stuff that we can opt into
for just the solve part.

Signed-off-by: Jon Johnson <[email protected]>
jonjohnsonjr added a commit to jonjohnsonjr/apko that referenced this pull request Jul 10, 2024
In the terraform module, we call BuildPackageList for each arch:
https://github.com/chainguard-dev/terraform-provider-apko/blob/812478b999411c183e87fefb9a9ece9fe7e8f2c1/internal/provider/config_data_source.go#L239

And then use that package list to actually build the image, so we
separate the solving from the building.

This bypasses chainguard-dev#1180 which
does this multi-arch constraining through a different entrypoint.

This adds another method to the multi-arch stuff that we can opt into
for just the solve part.

Signed-off-by: Jon Johnson <[email protected]>
jonjohnsonjr added a commit that referenced this pull request Jul 10, 2024
In the terraform module, we call BuildPackageList for each arch:
https://github.com/chainguard-dev/terraform-provider-apko/blob/812478b999411c183e87fefb9a9ece9fe7e8f2c1/internal/provider/config_data_source.go#L239

And then use that package list to actually build the image, so we
separate the solving from the building.

This bypasses #1180 which
does this multi-arch constraining through a different entrypoint.

This adds another method to the multi-arch stuff that we can opt into
for just the solve part.

To demonstrate this, I made `show-packages` use it:

```
diff --git a/examples/wolfi-base.yaml b/examples/wolfi-base.yaml
index d3ca2b8..0f0e979 100644
--- a/examples/wolfi-base.yaml
+++ b/examples/wolfi-base.yaml
@@ -4,7 +4,7 @@ contents:
   repositories:
     - https://packages.wolfi.dev/os
   packages:
-    - wolfi-base
+    - trivy~0.36.1
```

Before:

```
$ apko show-packages ./examples/wolfi-base.yaml
2024/07/10 13:06:01 INFO Determining packages for 2 architectures: [amd64 arm64]
2024/07/10 13:06:01 INFO setting apk repositories: [https://packages.wolfi.dev/os] arch=x86_64
2024/07/10 13:06:01 INFO using working directory /var/folders/96/3cdgttts3698hyjg_tydpw5c0000gn/T/apko-2043974002/x86_64 arch=x86_64
2024/07/10 13:06:01 INFO finished gathering apk info arch=x86_64
trivy 0.36.1-r1
2024/07/10 13:06:01 INFO setting apk repositories: [https://packages.wolfi.dev/os] arch=aarch64
2024/07/10 13:06:01 INFO using working directory /var/folders/96/3cdgttts3698hyjg_tydpw5c0000gn/T/apko-2043974002/aarch64 arch=aarch64
2024/07/10 13:06:01 INFO finished gathering apk info arch=aarch64
trivy 0.36.1-r2
```

After:

```
$ apko show-packages ./examples/wolfi-base.yaml
2024/07/10 13:06:25 INFO Determining packages for 2 architectures: [amd64 arm64]
2024/07/10 13:06:25 INFO setting apk repositories: [https://packages.wolfi.dev/os]
2024/07/10 13:06:25 INFO setting apk repositories: [https://packages.wolfi.dev/os]
2024/07/10 13:06:25 INFO packages for arm64
trivy 0.36.1-r1
2024/07/10 13:06:25 INFO packages for amd64
trivy 0.36.1-r1
```

I am using `trivy~0.36.1` as a constraint because we never indexed
`trivy-0.36.1-r2.apk` on `x86_64`, which means we'd solve for different
packages on each arch without this change.

Signed-off-by: Jon Johnson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants