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

fix multi arch build #33008

Conversation

alafanechere
Copy link
Contributor

@alafanechere alafanechere commented Dec 1, 2023

What

#32816 changed the way we load dagger-built container to local docker images.
We used docker import instead of docker load.
When using docker import we import a container filesystem as an image. Container filesystem can't be run as connector: they don't have entry points, env var, etc. set.
This is why we faced errors like:

$ docker run airbyte/destination-redshift:dev spec
docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "spec": executable file not found in $PATH: unknown.

Using docker load works better, but did not work for "multi arch" containers.

After deeply investigating I realize there's no such thing as a local multi arch docker image. Multi-arch images are only a docker registry thing: a docker manifest points to arch-specific images/layers and on pull the docker client pulls the correct image for the current architecture after reading the manifest.
In other words: there's no way to locally build a multi-arch image, either with docker or dagger.
But it's possible to have a local image built for a different architecture.

Now that I better understand the multi arch concept I change the --architecture option on build.
If you pass multiple --architecture you'll get multiple local images with architecture tag suffix:

  • airbyte/source-faker:dev-linux-arm64
  • airbyte/source-faker:dev-linux-amd64

If you pass a single --architecture you'll get:

  • airbyte/source-faker:dev built for the architecture option value

If you pass no --architecture option you'll get:

  • airbyte-/source-faker:dev built for your current architecture.

How

  • Use docker load instead o docker import
  • Implement the logic described above
  • Add a test to spot the kind of regression that originally happen: run spec on the loaded docker image.

Copy link

vercel bot commented Dec 1, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
airbyte-docs ⬜️ Ignored (Inspect) Visit Preview Dec 4, 2023 1:49pm

Copy link
Contributor Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

@alafanechere alafanechere force-pushed the augustin/12-01-fix_multi_arch_build branch from 8abb145 to 81a0c2c Compare December 1, 2023 09:24
@alafanechere alafanechere force-pushed the bnchrch/ci/revert-revert-new-arch-flags branch from 30fcab8 to c8bf267 Compare December 1, 2023 09:40
@alafanechere alafanechere force-pushed the augustin/12-01-fix_multi_arch_build branch from 1839086 to b81816b Compare December 1, 2023 09:42
@octavia-squidington-iii octavia-squidington-iii removed the area/connectors Connector related issues label Dec 1, 2023
@alafanechere alafanechere marked this pull request as ready for review December 1, 2023 09:42
@alafanechere alafanechere requested review from a team and bnchrch December 1, 2023 09:42
@alafanechere alafanechere force-pushed the augustin/12-01-fix_multi_arch_build branch from f22c122 to ed2441b Compare December 1, 2023 14:59
Copy link
Contributor

@bnchrch bnchrch left a comment

Choose a reason for hiding this comment

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

Good deep diving! Interesting findings! Great Code!

Nothing blocking

return StepResult(self, StepStatus.FAILURE, stderr=f"Something went wrong while interacting with the local docker client: {e}")
try:
client = docker.from_env()
image_tag = f"{self.image_tag}-{platform.replace('/', '-')}" if multi_platforms else self.image_tag
Copy link
Contributor

Choose a reason for hiding this comment

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

💅 Can be useful to have title transforms named

Suggested change
image_tag = f"{self.image_tag}-{platform.replace('/', '-')}" if multi_platforms else self.image_tag
image_tag = _generate_dev_tag(self.image_tag, platform, multi_platforms=multi_platforms)

That way you can contain the why

def _generate_dev_tag(image_tag, platform, multi_platforms):
    """
    Explain that multi archecture dev builds are not possible
    """
    return f"{self.image_tag}-{platform.replace('/', '-')}" if multi_platforms else self.image_tag

@octavia-squidington-iv octavia-squidington-iv requested a review from a team December 1, 2023 21:09
@katmarkham katmarkham removed the request for review from a team December 4, 2023 06:21
@alafanechere alafanechere force-pushed the bnchrch/ci/revert-revert-new-arch-flags branch from c8bf267 to 161d3e9 Compare December 4, 2023 09:12
@alafanechere alafanechere force-pushed the augustin/12-01-fix_multi_arch_build branch 3 times, most recently from c432d95 to 91139fe Compare December 4, 2023 13:45
@alafanechere alafanechere force-pushed the augustin/12-01-fix_multi_arch_build branch from 91139fe to 784475a Compare December 4, 2023 13:49
@alafanechere alafanechere merged commit 91bbdbf into bnchrch/ci/revert-revert-new-arch-flags Dec 4, 2023
21 of 22 checks passed
@alafanechere alafanechere deleted the augustin/12-01-fix_multi_arch_build branch December 4, 2023 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants