Skip to content

enable multi exporters#1788

Closed
fahedouch wants to merge 1 commit intomoby:masterfrom
fahedouch:enable-multi-exporters
Closed

enable multi exporters#1788
fahedouch wants to merge 1 commit intomoby:masterfrom
fahedouch:enable-multi-exporters

Conversation

@fahedouch
Copy link
Copy Markdown
Contributor

Signed-off-by: fahed dorgaa fahed.dorgaa@gmail.com

Clean branch from #1575.

building #1555

@fahedouch fahedouch mentioned this pull request Nov 10, 2020
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;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We shouldn't break API compatibility

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@AkihiroSuda are you talking about introducing new type ExporterAttrs ? If so, I did it because we can't do repeated map<string, string> .

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not only ExportAttrs. All fields need to keep same field number and type.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@AkihiroSuda done.

@AkihiroSuda
Copy link
Copy Markdown
Member

We also should have a new test for this

Comment thread api/services/control/control.proto Outdated
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;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of managing 2 arrays just add a single array with message that contains the name and attrs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed.

Comment thread client/solve.go Outdated
}
if ex.OutputDir != "" {
return nil, errors.Errorf("output directory %s is not supported by %s exporter", ex.OutputDir, ex.Type)
duplicateLocalExporter := 0
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

use map for this map[string]struct{} to set/check for duplicates so no new var is needed when another exporter is added.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed.

Comment thread client/solve.go Outdated
ExporterAttrs: make(map[string]string),
}

if len(opt.Exports) > 1 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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 ?

Comment thread client/solve.go Outdated
}

var exportersResponse []*controlapi.ExporterResponse
for _, v := range resp.ExportersResponse {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If this is nil need to handle the old field.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

Comment thread client/solve.go Outdated
for indexJSONPath, tag := range cacheOpt.indicesToUpdate {
if err = ociindex.PutDescToIndexJSONFileLocked(indexJSONPath, manifestDesc, tag); err != nil {
return nil, err
if len(res.ExportersResponse) > 0 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this len check is not needed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread cmd/buildctl/build/output.go Outdated
e, err := parseOutputCSV(s)
if err != nil {
return nil, err
if len(exports) > 0 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

how come this is not a for loop?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread control/control.go
return nil, err
}
}
if req.Exporters != nil {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread control/control.go
}
return &controlapi.SolveResponse{
ExporterResponse: resp.ExporterResponse,
ExportersResponse: resp.ExportersResponse,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Need to set old field as well with the result of the first element.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

Comment thread exporter/exporter.go
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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not a huge issue but ideally we don't use the proto types in here. Can be just array of maps.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

@tonistiigi tonistiigi self-requested a review November 28, 2020 01:24
@fahedouch fahedouch force-pushed the enable-multi-exporters branch from 6f33ad2 to 25d1260 Compare November 28, 2020 09:22
@fahedouch fahedouch closed this Dec 6, 2020
@fahedouch fahedouch reopened this Dec 6, 2020
@AkihiroSuda
Copy link
Copy Markdown
Member

needs rebase

@fahedouch fahedouch force-pushed the enable-multi-exporters branch from ae42e42 to 1a21397 Compare April 28, 2021 08:46
@fahedouch
Copy link
Copy Markdown
Contributor Author

fahedouch commented Apr 28, 2021

@AkihiroSuda rebased and squashed

@fahedouch fahedouch force-pushed the enable-multi-exporters branch 2 times, most recently from 041afaf to fe3bb9c Compare April 28, 2021 11:58
@tonistiigi
Copy link
Copy Markdown
Member

I can't start CI in this PR. Maybe a repush will fix it.

@tonistiigi tonistiigi added this to the v0.9.0 milestone Jun 11, 2021
@AkihiroSuda AkihiroSuda reopened this Jun 11, 2021
Signed-off-by: fahed dorgaa <fahed.dorgaa@gmail.com>
@fahedouch fahedouch force-pushed the enable-multi-exporters branch from fe3bb9c to 54e08a0 Compare June 11, 2021 09:09
@fahedouch
Copy link
Copy Markdown
Contributor Author

I can't start CI in this PR. Maybe a repush will fix it.

I did a force push. It looks like a problem on CI triggering.

@crazy-max
Copy link
Copy Markdown
Member

@fahedouch

Should be ok now.

@tonistiigi
Copy link
Copy Markdown
Member

@fahedouch Looks like a lot of red in the CI. PTAL. Or if you have questions about things you want comments before lmk.

@crazy-max
Copy link
Copy Markdown
Member

#2760

@crazy-max crazy-max closed this Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants