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

Allow Actions Github Client HTTP timeout to be configurable #3782

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
13 changes: 12 additions & 1 deletion github/actions/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"math/rand"
"net/http"
"net/url"
"os"
"strconv"
"sync"
"time"
Expand Down Expand Up @@ -209,7 +210,17 @@ func NewClient(githubConfigURL string, creds *ActionsAuth, options ...ClientOpti
retryClient.RetryMax = ac.retryMax
retryClient.RetryWaitMax = ac.retryWaitMax

retryClient.HTTPClient.Timeout = 5 * time.Minute // timeout must be > 1m to accomodate long polling
ts, found := os.LookupEnv("ACTIONS_HTTP_CLIENT_TIMEOUT_SECONDS")
if !found {
// Default to 5 minutes
// timeout must be > 1m to accommodate long polling
ts = "300"
}
timeout, err := strconv.ParseInt(ts, 10, 64)
if err != nil {
return nil, fmt.Errorf("failed to convert ACTIONS_HTTP_CLIENT_TIMEOUT_SECONDS to int64: %v", err)
}
retryClient.HTTPClient.Timeout = time.Duration(timeout) * time.Second

transport, ok := retryClient.HTTPClient.Transport.(*http.Transport)
if !ok {
Expand Down