Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not retry job when unknown status #1335

Merged
merged 1 commit into from
May 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion dkron/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"net"
"strings"
"time"

metrics "github.com/armon/go-metrics"
Expand Down Expand Up @@ -205,8 +206,12 @@ func (grpcs *GRPCServer) ExecutionDone(ctx context.Context, execDoneReq *proto.E
}

// If the execution failed, retry it until retries limit (default: don't retry)
// Don't retry if the status is unknown
execution := NewExecutionFromProto(&pbex)
if !execution.Success && uint(execution.Attempt) < job.Retries+1 {
if !execution.Success &&
uint(execution.Attempt) < job.Retries+1 &&
!strings.HasPrefix(execution.Output, ErrBrokenStream.Error()) {
// Increment the attempt counter
execution.Attempt++

// Keep all execution properties intact except the last output
Expand Down
2 changes: 1 addition & 1 deletion dkron/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ func (grpcc *GRPCClient) AgentRun(addr string, job *proto.Job, execution *proto.
if err != nil {
// At this point the execution status will be unknown, set the FinishedAt time and an explanatory message
execution.FinishedAt = ptypes.TimestampNow()
execution.Output = []byte(err.Error())
execution.Output = []byte(ErrBrokenStream.Error() + ": " + err.Error())

grpcc.logger.WithError(err).Error(ErrBrokenStream)

Expand Down