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

Resolver: ensure WithSession to pass the session to the resolver #2600

Merged
merged 1 commit into from
Feb 9, 2022

Conversation

ktock
Copy link
Collaborator

@ktock ktock commented Feb 7, 2022

Currently, unlazying blobs created by the previous build seems to fail because resolver.Resolver.WithSession() doesn't propagate session to authorizer during unlazying.
This commit fixes this issue.

reproducing issue

  • buildkit version: master (a640b47)
# cat <<EOF > /tmp/ctx/Dockerfile
FROM ghcr.io/stargz-containers/ubuntu:20.04-org
EOF
# buildctl build --progress=plain --frontend=dockerfile.v0 --local context=/tmp/ctx --local dockerfile=/tmp/ctx
# buildctl build --progress=plain --frontend=dockerfile.v0 --local context=/tmp/ctx --local dockerfile=/tmp/ctx \
                 --output type=oci,dest=/tmp/out.tar,oci-mediatypes=true,compression=zstd,force-compression=true

The second build in the above fails with the following error:

ERRO[2022-02-07T06:11:09Z] /moby.buildkit.v1.Control/Solve returned error: rpc error: code = Unknown desc = failed to ensure compression type of "zstd": failed to copy: httpReadSeeker: failed open: no active sessions
full log
# buildctl build --progress=plain --frontend=dockerfile.v0 --local context=/tmp/ctx --local dockerfile=/tmp/ctx
#1 [internal] load build definition from Dockerfile
#1 DONE 0.0s

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 85B done
#1 DONE 0.0s

#2 [internal] load .dockerignore
#2 transferring context: 2B done
#2 DONE 0.1s

#3 [internal] load metadata for ghcr.io/stargz-containers/ubuntu:20.04-org
#3 DONE 0.4s

#4 [1/1] FROM ghcr.io/stargz-containers/ubuntu:20.04-org@sha256:adf73ca014822ad8237623d388cedf4d5346aa72c270c5acc01431cc93e18e2d
#4 resolve ghcr.io/stargz-containers/ubuntu:20.04-org@sha256:adf73ca014822ad8237623d388cedf4d5346aa72c270c5acc01431cc93e18e2d 0.0s done
#4 DONE 0.0s

#4 [1/1] FROM ghcr.io/stargz-containers/ubuntu:20.04-org@sha256:adf73ca014822ad8237623d388cedf4d5346aa72c270c5acc01431cc93e18e2d
#4 DONE 0.1s


# buildctl build --progress=plain --frontend=dockerfile.v0 --local context=/tmp/ctx --local dockerfile=/tmp/ctx \
                 --output type=oci,dest=/tmp/out.tar,oci-mediatypes=true,compression=zstd,force-compression=true
#1 [internal] load build definition from Dockerfile
#1 DONE 0.0s

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 85B done
#1 DONE 0.0s

#2 [internal] load .dockerignore
#2 transferring context: 2B done
#2 DONE 0.0s

#3 [internal] load metadata for ghcr.io/stargz-containers/ubuntu:20.04-org
#3 DONE 0.7s

#4 [1/1] FROM ghcr.io/stargz-containers/ubuntu:20.04-org@sha256:adf73ca014822ad8237623d388cedf4d5346aa72c270c5acc01431cc93e18e2d
#4 resolve ghcr.io/stargz-containers/ubuntu:20.04-org@sha256:adf73ca014822ad8237623d388cedf4d5346aa72c270c5acc01431cc93e18e2d 0.0s done
#4 sha256:5e9250ddb7d0fa6d13302c7c3e6a0aa40390e42424caed1e5289077ee4054709 0B / 187B 0.2s
ERRO[2022-02-07T06:11:09Z] /moby.buildkit.v1.Control/Solve returned error: rpc error: code = Unknown desc = failed to ensure compression type of "zstd": failed to copy: httpReadSeeker: failed open: no active sessions 
#4 DONE 0.2s

#5 exporting to oci image format
#5 exporting layers 0.2s done
#5 ERROR: failed to ensure compression type of "zstd": failed to copy: httpReadSeeker: failed open: no active sessions
------
 > exporting to oci image format:
------
error: failed to solve: failed to ensure compression type of "zstd": failed to copy: httpReadSeeker: failed open: no active sessions

@tonistiigi
Copy link
Member

Can you explain why this requires compression=zstd,force-compression=true to trigger and otherwise seems to work as is. I'm not sure I understand what the actual error case is and why r2.auth = nil is not enough here.

@ktock
Copy link
Collaborator Author

ktock commented Feb 8, 2022

@tonistiigi

Can you explain why this requires compression=zstd,force-compression=true to trigger and otherwise seems to work as is.

The first build creates new refs for ghcr.io/stargz-containers/ubuntu:20.04-org using cache.*cacheManager.GetByBlob() but it doesn't unlazy them becuse of no export.

The second build uses these cached refs and unlazies for exporting them. Now, the session provided to an argument of cache.*immutableRef.GetRemotes() is passed to (util/pull).*PullManifests.Provider(session.Group) via lazyRefProvider. (util/pull).*PullManifests.Provider(session.Group) creates a new resolver using (util/resolver).*Resolver.WithSession() with the provided session.

However, WithSession() doesn't seem to copy (util/resolver).*Resolver.Resolver which still points to the older (util/resolver).*Resolver.g via (util/resolver).*Resolver.HostsFunc().

(BTW, *Resolver.auth doesn't seem to be used as of now? maybe I'm missing something)

@tonistiigi tonistiigi merged commit a813906 into moby:master Feb 9, 2022
@tonistiigi
Copy link
Member

*Resolver.auth doesn't seem to be used as of now? maybe I'm missing something

Indeed. Think we can clean it up.

@ktock ktock deleted the fixconversionfailure branch July 31, 2022 02:13
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