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

Cannot build app with podman and pack v0.32+ #2000

Closed
matejvasek opened this issue Dec 7, 2023 · 16 comments · Fixed by #2027
Closed

Cannot build app with podman and pack v0.32+ #2000

matejvasek opened this issue Dec 7, 2023 · 16 comments · Fixed by #2027
Assignees
Labels
status/ready Issue ready to be worked on. type/bug Issue that reports an unexpected behaviour.
Milestone

Comments

@matejvasek
Copy link
Contributor

matejvasek commented Dec 7, 2023

Summary

Building an app using pack and podman fails with message:

ERROR: failed to build: failed to write image to the following tags: [pack.local/builder/71706f696b6577696675:latest: expected config hash "01940b90b5c5a92125b3eabce41d6f2824bf65bcb8c64c50944e437bd2ede1f8"; got "7c7bff10088f1a8fff50a26d68f1e52eb621296146867c6324e3ddfd50741189"]

The regression seems to be introduced in buildpacks/imgutil@67824e9 before it worked.

Reproduction

Steps
Current behavior
Expected behavior

Environment

pack info
docker info
@matejvasek matejvasek added status/triage Issue or PR that requires contributor attention. type/bug Issue that reports an unexpected behaviour. labels Dec 7, 2023
@matejvasek
Copy link
Contributor Author

/cc @natalieparellano

@natalieparellano
Copy link
Member

@matejvasek thanks for this. I think we have a couple options here:

  1. Revert to old imgutil; the "fix" I introduced is more of a hack and we hope to solve it more cleanly via other mechanisms
  2. Remove this check as it seems too brittle

@jabrown85 do you have any thoughts here?

@natalieparellano natalieparellano added status/ready Issue ready to be worked on. and removed status/triage Issue or PR that requires contributor attention. labels Dec 11, 2023
@jabrown85
Copy link
Contributor

I'd be curious to cut a version without the the validate and see if the image is as expected. Can you share your podman information? Does this happen on fresh builds or re-builds?

@matejvasek
Copy link
Contributor Author

When I neutralize the validateInspect() then the build proceeds and it looks like the app image is OK (I tested only Go Hello World program).

@matejvasek
Copy link
Contributor Author

The error happens even on supposedly clean build (new image name).

@matejvasek
Copy link
Contributor Author

matejvasek commented Dec 11, 2023

podman system service unix:///tmp/docker.sock --log-level=debug --time 0
export DOCKER_HOST=unix:///tmp/docker.sock
pack build applications/golang2 -Bghcr.io/knative/builder-jammy-tiny:latest --docker-host=inherit --trust-builder=1 --path=/tmp/tmp.UVLH8A9F24

@jjbustamante
Copy link
Member

I will suggest option 2 and remove the validateInspect, I think we didn't do before and everything was working with podman

@natalieparellano
Copy link
Member

We used to do the check with inspect, _, err := i.docker.ImageInspectWithRaw(context.Background(), id) where id := fmt.Sprintf("%x", sha256.Sum256(configFile)) and configFile is the file we generated. So in theory, the check should be equivalent but somewhere it's gone wrong...

@natalieparellano
Copy link
Member

IMO it would be safer to just roll back imgutil until we can understand what changed.

@matejvasek
Copy link
Contributor Author

What two digests are being compared? One in daemon and another in tar, or what is being compared?

@matejvasek
Copy link
Contributor Author

What exactly is happening? Are we crafting image tar that is subsequently loaded into daemon?

@natalieparellano
Copy link
Member

@matejvasek we used to compare the digest of the config file that we loaded to the image ID returned by inspect. I believe this is to protect against collisions, in case two image builds with the same tag are happening in parallel. When we added the workaround for containerd storage, we stopped using the image ID in the comparison, because the ID when containerd storage is used is the digest of the manifest. Instead, we compute the digest again and check that it matches what we sent in.

@natalieparellano natalieparellano added this to the 0.33.0 milestone Jan 10, 2024
@matejvasek
Copy link
Contributor Author

@natalieparellano I was not watching this for some time, is there any progress on this issue?

@natalieparellano
Copy link
Member

@matejvasek I think we just need to remove the digest comparison in imgutil. It should be a quick fix.

natalieparellano added a commit to buildpacks/imgutil that referenced this issue Jan 17, 2024
Before #222, we calculated the sha of the config file that we sent to the daemon,
and verified that we could inspect an image with that ID.

After #222, since the image ID may be the sha of the config file or the sha of the manifest file
(depending on whether containerd storage is enabled),
we still calculated the sha of the config file that we sent to the daemon,
but instead of trying to inspect an image with that ID,
we inspected the image by name, derived the config file from the data we got back from inspect,
and then verified that the sha of the derived config file matches the sha of the config file that we sent in.

This check turned out to be brittle
(see buildpacks/pack#2000 and https://cloud-native.slack.com/archives/C0331B61A1Y/p1701976103265489)
and we agreed that it should be safe to remove this check.

Signed-off-by: Natalie Arellano <[email protected]>
@natalieparellano
Copy link
Member

This should be fixed in buildpacks/imgutil#239 - I believe all that is left is to update the imgutil version in pack (cc @jjbustamante)

@jjbustamante
Copy link
Member

This should be fixed in buildpacks/imgutil#239 - I believe all that is left is to update the imgutil version in pack (cc @jjbustamante)

I will create a PR to bump the imgutil version 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/ready Issue ready to be worked on. type/bug Issue that reports an unexpected behaviour.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants