Skip to content

Commit

Permalink
Merge pull request #243 from depot/fix/report-buildx-errors
Browse files Browse the repository at this point in the history
fix(buildx): report errors when builds finish
  • Loading branch information
goller authored Jan 31, 2024
2 parents 6ca1c82 + e48a36b commit 95e2653
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions pkg/cmd/buildctl/dial-stdio.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func run() error {
}
}

acquireState := func() ProxyState {
acquireState := func() *ProxyState {
once.Do(func() {
req := &cliv1.CreateBuildRequest{
ProjectId: &projectID,
Expand Down Expand Up @@ -193,7 +193,7 @@ func run() error {
return nil
})
})
return state
return &state
}

buildx := &StdioConn{}
Expand Down
22 changes: 13 additions & 9 deletions pkg/cmd/buildctl/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func BuildkitdClient(ctx context.Context, conn net.Conn, buildkitdAddress string
}

// Proxy buildkitd server over connection. Cancel context to shutdown.
func Proxy(ctx context.Context, conn net.Conn, acquireState func() ProxyState, platform string, status chan *client.SolveStatus) {
func Proxy(ctx context.Context, conn net.Conn, acquireState func() *ProxyState, platform string, status chan *client.SolveStatus) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()

Expand Down Expand Up @@ -101,11 +101,11 @@ type ProxyState struct {
Conn *grpc.ClientConn // Conn is the connection to the buildkitd server.
SummaryURL string // SummaryURL is the UI summary page.
Reporter *progress.Progress // Reporter forwards status events to the API.
Err error // Err is set when the connection cannot be established.
Err error // Err is set when the connection cannot be established or the build fails.
}

type ControlProxy struct {
state func() ProxyState
state func() *ProxyState
status chan *client.SolveStatus
platform string
cancel context.CancelFunc
Expand Down Expand Up @@ -166,7 +166,11 @@ func (p *ControlProxy) Solve(ctx context.Context, in *control.SolveRequest) (*co
client := control.NewControlClient(state.Conn)
// DEPOT: stop recording the build steps and traces on the server.
in.Internal = true
return client.Solve(ctx, in)
res, err := client.Solve(ctx, in)
if err != nil {
state.Err = err
}
return res, err
}

func (p *ControlProxy) Status(in *control.StatusRequest, toBuildx control.Control_StatusServer) error {
Expand Down Expand Up @@ -406,7 +410,7 @@ func (p *ControlProxy) UpdateBuildHistory(ctx context.Context, in *control.Updat
}

type GatewayProxy struct {
state func() ProxyState
state func() *ProxyState
platform string
}

Expand Down Expand Up @@ -624,7 +628,7 @@ func (p *GatewayProxy) Warn(ctx context.Context, in *gateway.WarnRequest) (*gate
}

type TracesProxy struct {
state func() ProxyState
state func() *ProxyState
trace.UnimplementedTraceServiceServer
}

Expand All @@ -648,7 +652,7 @@ func (p *TracesProxy) Export(ctx context.Context, in *trace.ExportTraceServiceRe
}

type ContentProxy struct {
state func() ProxyState
state func() *ProxyState
}

func (p *ContentProxy) Info(ctx context.Context, in *content.InfoRequest) (*content.InfoResponse, error) {
Expand Down Expand Up @@ -855,7 +859,7 @@ func (p *ContentProxy) Abort(ctx context.Context, in *content.AbortRequest) (*ty
}

type LeasesProxy struct {
state func() ProxyState
state func() *ProxyState
}

func (p *LeasesProxy) Delete(ctx context.Context, in *leases.DeleteRequest) (*types.Empty, error) {
Expand Down Expand Up @@ -949,7 +953,7 @@ func (p *LeasesProxy) ListResources(ctx context.Context, in *leases.ListResource
}

type HealthProxy struct {
state func() ProxyState
state func() *ProxyState
}

func (p *HealthProxy) Check(ctx context.Context, in *health.HealthCheckRequest) (*health.HealthCheckResponse, error) {
Expand Down

0 comments on commit 95e2653

Please sign in to comment.