Change result type to array of refs#1269
Conversation
Signed-off-by: Edgar Lee <edgarl@netflix.com>
I think it makes sense do to this when we can update the exporters as well. It may even be needed to pass the ability to receive arrays based on exporter. All current builtin exporters should support it but current moby exporter would be problematic (that being said there is a branch where moby exporter doesn't exist any more). If we don't add all that atm, then we should make sure to error whenever array with more than one item is returned. Also, we wouldn't add api cap now but when it is actually possible to return multiple items.
Ideally I thought
Tests would come when it is possible to return multiple items. Atm just needs to keep everything working. CI is not passing atm, btw |
|
Please sign your commits following these rules: $ git clone -b "ref-array" git@github.com:hinshun/buildkit.git somewhere
$ cd somewhere
$ git rebase -i HEAD~842353889080
editor opens
change each 'pick' to 'edit'
save the file and quit
$ git commit --amend -s --no-edit
$ git rebase --continue # and repeat the amend for each commit
$ git push -fAmending updates the existing PR. You DO NOT need to open a new one. |
Signed-off-by: Edgar Lee <edgarl@netflix.com>
|
@hinshun Is this ready? I see the erroring on multi-result array is not implemented. This is actually a bit problematic because if we pass |
|
@tonistiigi This isn't ready yet because I wanted to explore how #751 would be implemented first. In this #751 (comment), you mentioned:
I think that means we need both edge digests and edge indices right? message Ref {
repeated string ids = 1;
repeated string edgeDigests = 2;
repeated string edgeIndices = 3;
}Alternatively, we should just add yet another type for the message Result {
oneof result {
// Deprecated non-array refs.
string refDeprecated = 1;
RefMapDeprecated refsDeprecated = 2;
RefArray refArray = 3;
RefMap refMap = 4;
}
map<string, bytes> metadata = 10;
}
message RefMapDeprecated {
map<string, string> refs = 1;
}
message RefArray {
repeated Ref refs = 1;
}
message Ref {
string id = 1;
string digest = 2;
string index = 3;
}
message RefMap {
map<string, RefArray> refArraysByID = 1;
} |
| if len(ids) == 0 { | ||
| return nil, nil | ||
| } | ||
|
|
There was a problem hiding this comment.
I'm assuming this is where the error checking for multi-result array to be? This is where the forwarder is handling the Return RPC from the frontend.
| } | ||
| case *pb.Result_Ref: | ||
| if ids := pbRes.Ref.Ids; len(ids) > 0 { | ||
| res.SetRef(&reference{id: ids[0], c: c}) |
There was a problem hiding this comment.
Originally, I wanted to just change the types to []string but only handle single element, but I think we should change these to support multi-result arrays right? i.e.
res.SetRef(&reference{id: ids, c: c})| for k, v := range pbRes.Refs.Refs { | ||
| var ref *reference | ||
| if len(v.Ids) > 0 { | ||
| ref = &reference{id: v.Ids[0], c: c} |
|
I see, I misunderstood what you meant! That makes sense now. |
Signed-off-by: Edgar Lee <edgarl@netflix.com>
Partially fixes #871
It moves non-array
refandrefsmap to array types while maintaining backwards compatibility. We need to detect clients without array ref capability (server need to detect client cap soapicapcan't be used here), soAllowResultArrayRefwas added.Previous proto fields
Result_RefandResult_RefMapwas moved toResult_RefDeprecatedandResult_RefMapDeprecatedrespectively.Some open questions:
buildkit/frontend/result.go
Lines 5 to 9 in 5c9365b
buildkit/frontend/gateway/client/result.go
Lines 12 to 17 in 5c9365b