enable multi exporters#1788
Conversation
| map<string, string> FrontendAttrs = 7; | ||
| CacheOptions Cache = 8 [(gogoproto.nullable) = false]; | ||
| repeated string Entitlements = 9 [(gogoproto.customtype) = "github.com/moby/buildkit/util/entitlements.Entitlement" ]; | ||
| map<string, pb.Definition> FrontendInputs = 10; |
There was a problem hiding this comment.
We shouldn't break API compatibility
There was a problem hiding this comment.
@AkihiroSuda are you talking about introducing new type ExporterAttrs ? If so, I did it because we can't do repeated map<string, string> .
There was a problem hiding this comment.
Not only ExportAttrs. All fields need to keep same field number and type.
|
We also should have a new test for this |
| CacheOptions Cache = 8 [(gogoproto.nullable) = false]; | ||
| repeated string Entitlements = 9 [(gogoproto.customtype) = "github.com/moby/buildkit/util/entitlements.Entitlement" ]; | ||
| map<string, pb.Definition> FrontendInputs = 10; | ||
| repeated string Exporters = 11; |
There was a problem hiding this comment.
Instead of managing 2 arrays just add a single array with message that contains the name and attrs.
| } | ||
| if ex.OutputDir != "" { | ||
| return nil, errors.Errorf("output directory %s is not supported by %s exporter", ex.OutputDir, ex.Type) | ||
| duplicateLocalExporter := 0 |
There was a problem hiding this comment.
use map for this map[string]struct{} to set/check for duplicates so no new var is needed when another exporter is added.
| ExporterAttrs: make(map[string]string), | ||
| } | ||
|
|
||
| if len(opt.Exports) > 1 { |
There was a problem hiding this comment.
we should set the array in all cases and deprecate the non-array field (still set it for old daemons). If possible we could maybe use caps to detect if daemon support array and error otherwise(not critical for this PR).
On daemon side if array is set then only use array, if array is not set then use the old field to support old clients.
There was a problem hiding this comment.
we should set the array in all cases and deprecate the non-array field => done.
for the second part, how should we test if daemon support array or not ?
| } | ||
|
|
||
| var exportersResponse []*controlapi.ExporterResponse | ||
| for _, v := range resp.ExportersResponse { |
There was a problem hiding this comment.
If this is nil need to handle the old field.
| for indexJSONPath, tag := range cacheOpt.indicesToUpdate { | ||
| if err = ociindex.PutDescToIndexJSONFileLocked(indexJSONPath, manifestDesc, tag); err != nil { | ||
| return nil, err | ||
| if len(res.ExportersResponse) > 0 { |
There was a problem hiding this comment.
this len check is not needed
| e, err := parseOutputCSV(s) | ||
| if err != nil { | ||
| return nil, err | ||
| if len(exports) > 0 { |
There was a problem hiding this comment.
how come this is not a for loop?
| return nil, err | ||
| } | ||
| } | ||
| if req.Exporters != nil { |
There was a problem hiding this comment.
if this is set, ignore req.Exporter. You can rename req.Exporter to ExporterDeprecated so it is clearer what fields are only for backward compatibility
There was a problem hiding this comment.
req.Exporter will be automaticaly ingnored if req.Exporters is set. Basically we cannot have both req.Exporters and req.Exporter so either req.Exporters or req.Exporter.
| } | ||
| return &controlapi.SolveResponse{ | ||
| ExporterResponse: resp.ExporterResponse, | ||
| ExportersResponse: resp.ExportersResponse, |
There was a problem hiding this comment.
Need to set old field as well with the result of the first element.
| type ExporterInstance interface { | ||
| Name() string | ||
| Export(ctx context.Context, src Source, sessionID string) (map[string]string, error) | ||
| Export(ctx context.Context, src Source, sessionID string) (*controlapi.ExporterResponse, error) |
There was a problem hiding this comment.
Not a huge issue but ideally we don't use the proto types in here. Can be just array of maps.
There was a problem hiding this comment.
if you dive a little bit in the PR you will that sometimes I append ExportersResponse with ExporterResponse So for this I should keep type compatibility between ExportersResponse and ExporterResponse
6f33ad2 to
25d1260
Compare
|
needs rebase |
ae42e42 to
1a21397
Compare
|
@AkihiroSuda rebased and squashed |
041afaf to
fe3bb9c
Compare
|
I can't start CI in this PR. Maybe a repush will fix it. |
Signed-off-by: fahed dorgaa <fahed.dorgaa@gmail.com>
fe3bb9c to
54e08a0
Compare
I did a force push. It looks like a problem on CI triggering. |
|
Should be ok now. |
|
@fahedouch Looks like a lot of red in the CI. PTAL. Or if you have questions about things you want comments before lmk. |
Signed-off-by: fahed dorgaa fahed.dorgaa@gmail.com
Clean branch from #1575.
building #1555