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

add missing fallback from new frontend to daemon without sourceresolver #4647

Merged
merged 2 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# syntax=docker/dockerfile-upstream:master
# syntax=docker/dockerfile-upstream:master@sha256:cd94315a37d63ca11498df06c59883d86fa5b662b0fe5dfee7ad5b7086e95fdf

ARG RUNC_VERSION=v1.1.12
ARG CONTAINERD_VERSION=v1.7.11
Expand Down
2 changes: 1 addition & 1 deletion frontend/dockerfile/cmd/dockerfile-frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# syntax=docker/dockerfile-upstream:master
# syntax=docker/dockerfile-upstream:master@sha256:cd94315a37d63ca11498df06c59883d86fa5b662b0fe5dfee7ad5b7086e95fdf

ARG GO_VERSION=1.21

Expand Down
26 changes: 25 additions & 1 deletion frontend/gateway/grpcclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,31 @@ func (c *grpcClient) Solve(ctx context.Context, creq client.SolveRequest) (res *

func (c *grpcClient) ResolveSourceMetadata(ctx context.Context, op *opspb.SourceOp, opt sourceresolver.Opt) (*sourceresolver.MetaResponse, error) {
if c.caps.Supports(pb.CapSourceMetaResolver) != nil {
return nil, errors.Errorf("fallback not implemented")
var ref string
if v, ok := strings.CutPrefix(op.Identifier, "docker-image://"); ok {
ref = v
} else if v, ok := strings.CutPrefix(op.Identifier, "oci-layout://"); ok {
ref = v
} else {
return &sourceresolver.MetaResponse{Op: op}, nil
}
retRef, dgst, config, err := c.ResolveImageConfig(ctx, ref, opt)
if err != nil {
return nil, err
}
if strings.HasPrefix(op.Identifier, "docker-image://") {
op.Identifier = "docker-image://" + retRef
} else if strings.HasPrefix(op.Identifier, "oci-layout://") {
op.Identifier = "oci-layout://" + retRef
Copy link
Member

@jedevc jedevc Feb 14, 2024

Choose a reason for hiding this comment

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

If HasPrefix, prepend it again? I assume the line above should be op.Identifier.

Copy link
Member

@jedevc jedevc Feb 14, 2024

Choose a reason for hiding this comment

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

I think this is still wrong. ref has had the prefix stripped already, so the condition never triggers.

This should be:

if strings.HasPrefix(op.Identifier, "docker-image://") {
	op.Identifier = "docker-image://" + retRef
}

That was we actually are checking the prefix, and making sure the output has the same prefix.

}

return &sourceresolver.MetaResponse{
Op: op,
Image: &sourceresolver.ResolveImageResponse{
Digest: dgst,
Config: config,
},
}, nil
}

var p *opspb.Platform
Expand Down