Skip to content

Commit

Permalink
Add eventV2.BuildCancelled (#6365)
Browse files Browse the repository at this point in the history
* Add eventV2.BuildCancelled

* conditionally send canceled events

* add output for canceled build

* use errors.Is()

Co-authored-by: Marlon Gamez <marlongamez98@gmail.com>
  • Loading branch information
tejal29 and MarlonGamez authored Aug 5, 2021
1 parent 18a8cd8 commit b299c57
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/skaffold/build/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package build

import (
"context"
"errors"
"fmt"
"io"
"strconv"
Expand Down Expand Up @@ -86,6 +87,7 @@ func (s *scheduler) build(ctx context.Context, tags tag.ImageTags, i int) error
if err != nil {
// `waitForDependencies` only returns `context.Canceled` error
event.BuildCanceled(a.ImageName)
eventV2.BuildCanceled(a.ImageName, err)
return err
}
release := s.concurrencySem.acquire()
Expand All @@ -112,7 +114,12 @@ func (s *scheduler) build(ctx context.Context, tags tag.ImageTags, i int) error
finalTag, err := performBuild(ctx, w, tags, a, s.artifactBuilder)
if err != nil {
event.BuildFailed(a.ImageName, err)
eventV2.BuildFailed(a.ImageName, err)
if errors.Is(ctx.Err(), context.Canceled) {
output.Yellow.Fprintf(w, "Canceled build for %s\n", a.ImageName)
eventV2.BuildCanceled(a.ImageName, err)
} else {
eventV2.BuildFailed(a.ImageName, err)
}
endTrace(instrumentation.TraceEndError(err))
return err
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/skaffold/event/v2/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ func BuildSucceeded(artifact string) {
buildSubtaskEvent(artifact, Build, Succeeded, nil)
}

func BuildCanceled(artifact string, err error) {
buildSubtaskEvent(artifact, Build, Canceled, err)
}

func buildSubtaskEvent(artifact, step, status string, err error) {
var aErr *proto.ActionableErr
if err != nil {
Expand Down

0 comments on commit b299c57

Please sign in to comment.