Skip to content

Commit

Permalink
fix: adding nil check for job spec retry behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
kushsharma committed Jun 23, 2021
1 parent 16d79f1 commit e08abe6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions api/handler/v1/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,14 @@ func (adapt *Adapter) FromJobProto(spec *pb.JobSpecification) (models.JobSpec, e
}

retryDelay := time.Duration(0)
if spec.Behavior != nil && spec.Behavior.Retry.Delay != nil && spec.Behavior.Retry.Delay.IsValid() {
retryDelay = spec.Behavior.Retry.Delay.AsDuration()
retryCount := 0
retryExponentialBackoff := false
if spec.Behavior != nil && spec.Behavior.Retry != nil {
retryCount = int(spec.Behavior.Retry.Count)
retryExponentialBackoff = spec.Behavior.Retry.ExponentialBackoff
if spec.Behavior.Retry.Delay != nil && spec.Behavior.Retry.Delay.IsValid() {
retryDelay = spec.Behavior.Retry.Delay.AsDuration()
}
}
return models.JobSpec{
Version: int(spec.Version),
Expand All @@ -90,9 +96,9 @@ func (adapt *Adapter) FromJobProto(spec *pb.JobSpecification) (models.JobSpec, e
DependsOnPast: spec.DependsOnPast,
CatchUp: spec.CatchUp,
Retry: models.JobSpecBehaviorRetry{
Count: int(spec.Behavior.Retry.Count),
Count: retryCount,
Delay: retryDelay,
ExponentialBackoff: spec.Behavior.Retry.ExponentialBackoff,
ExponentialBackoff: retryExponentialBackoff,
},
},
Task: models.JobSpecTask{
Expand Down

0 comments on commit e08abe6

Please sign in to comment.