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

missing provenance errors when context does not exist #3928

Closed
nicks opened this issue Jun 2, 2023 · 3 comments · Fixed by #3945
Closed

missing provenance errors when context does not exist #3928

nicks opened this issue Jun 2, 2023 · 3 comments · Fixed by #3945

Comments

@nicks
Copy link
Contributor

nicks commented Jun 2, 2023

Description

If I try to build from the API without a context, I get an error like:

missing provenance for fuqamtlkfg8ef41sv5ivh9bn6

Repro steps

I wrote a little tool for debugging the buildkit api.

  1. Create a Dockerfile like this:
FROM alpine
  1. Checkout my buildkitapi debugger
git clone [email protected]:tilt-dev/tilt
cd tilt
go install ./cmd/buildkitapi

there's nothing special in this script, it uses the docker client libraries to talk to the ImageBuild api in docker engine

https://github.com/tilt-dev/tilt/blob/master/cmd/buildkitapi/main.go

  1. In the directory with your dockerfile, run:
$ buildkitapi --context missing-dir --legacy
{"errorDetail":{"message":"missing provenance for l4rd8x27he7k4hcsmi9gq40w3"},"error":"missing provenance for l4rd8x27he7k4hcsmi9gq40w3"}

Expected result

No error

Additional info

This is a recent regression that started happening with Docker Engine 24.0 / Docker Desktop 4.20

Boiled down from tilt-dev/tilt#6125

@nicks nicks changed the title missing provenance errors when context missing provenance errors when context does not exist Jun 2, 2023
@jedevc
Copy link
Member

jedevc commented Jun 7, 2023

So I can reproduce this 🎉

This is a bit fiddly. Here's my guess as to what's happening:

  • The context directory doesn't exist. If we try and access it, bad things happen.
  • On build, we try to sync over the .dockerignore file. This adds it to the provenance bridge. However, we silently drop failures to read the .dockerignore file.
  • When generating provenance, we try and read from the provenance bridge... but since we hit an error, we never managed to get the provenance recorded (even though the result is there).

I think the provenance code expects frontend calls to solve to be propagated, instead of silently being discarded (as we do for the dockerignore). Not quite sure what we expect to do here.

I wonder if we just should skip this provenance case? And not skip past when we're recorded an error?

Or maybe we should propagate certain types of dockerignore read failures, instead of the broad err == nil?

dt, err = ref.ReadFile(ctx, client.ReadRequest{
Filename: bctx.filename + ".dockerignore",
})
if err == nil {
bc.dockerignore = dt
}

@jedevc
Copy link
Member

jedevc commented Jun 7, 2023

To add on - I think the correct call is that the client should be checking that the directory needs to exist - but also, there are plenty of edge-cases where you could imagine a directory being deleted halfway through a build or similar, so we still need to fix this.

@jedevc
Copy link
Member

jedevc commented Jun 9, 2023

Managed to write a failing test case: b35f95a. Since the context isn't accessed in the Dockerfile, then the build shouldn't fail.

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 a pull request may close this issue.

2 participants