Skip to content

Commit

Permalink
Merge pull request #27 from harness/tar
Browse files Browse the repository at this point in the history
feat: [CI-11274]: Added retries sending step status
  • Loading branch information
vistaarjuneja authored Feb 8, 2024
2 parents d7ab998 + d736476 commit b220c3e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions delegate/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ const (
)

var (
registerTimeout = 30 * time.Second
taskEventsTimeout = 60 * time.Second
registerTimeout = 30 * time.Second
taskEventsTimeout = 60 * time.Second
sendStatusRetryTimes = 5
)

// defaultClient is the default http.Client.
Expand Down Expand Up @@ -191,7 +192,15 @@ func (p *HTTPClient) Acquire(ctx context.Context, delegateID, taskID string) (*c
func (p *HTTPClient) SendStatus(ctx context.Context, delegateID, taskID string, r *client.TaskResponse) error {
path := fmt.Sprintf(taskStatusEndpoint, taskID, delegateID, p.AccountID)
req := r
_, err := p.retry(ctx, path, "POST", req, nil, createBackoff(ctx, taskEventsTimeout), true) //nolint: bodyclose
retryNumber := 0
var err error
for retryNumber < sendStatusRetryTimes {
_, err = p.retry(ctx, path, "POST", req, nil, createBackoff(ctx, taskEventsTimeout), true) //nolint: bodyclose
if err == nil {
return nil
}
retryNumber++
}
return err
}

Expand Down

0 comments on commit b220c3e

Please sign in to comment.