Skip to content

Commit

Permalink
Capture more command cancellations (#3871)
Browse files Browse the repository at this point in the history
Some of the new command manifest values are being marked as failures
rather than cancellations.
  • Loading branch information
mikejholly authored Mar 6, 2024
1 parent 88fa60d commit a36d787
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion logbus/command.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package logbus

import (
"context"
"sync"
"sync/atomic"
"time"

"github.com/earthly/cloud-api/logstream"
"github.com/earthly/earthly/util/circbuf"
"github.com/pkg/errors"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)

const (
Expand Down Expand Up @@ -144,8 +147,12 @@ func (c *Command) SetEndError(err error) {
now := time.Now()

if err != nil {
st := logstream.RunStatus_RUN_STATUS_FAILURE
if errors.Is(err, context.Canceled) || status.Code(err) == codes.Canceled {
st = logstream.RunStatus_RUN_STATUS_CANCELED
}
c.commandDelta(&logstream.DeltaCommandManifest{
Status: logstream.RunStatus_RUN_STATUS_FAILURE,
Status: st,
ErrorMessage: err.Error(),
EndedAtUnixNanos: c.b.TsUnixNanos(now),
})
Expand Down

0 comments on commit a36d787

Please sign in to comment.