From 168c90057bbb18670d759a46c4a098e544d1154d Mon Sep 17 00:00:00 2001 From: "jordan.brown" Date: Mon, 21 Oct 2024 13:50:31 -0700 Subject: [PATCH 1/2] lower retryClient timeout to 90s --- github/actions/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/actions/client.go b/github/actions/client.go index 2b40ffce92..248c38ad27 100644 --- a/github/actions/client.go +++ b/github/actions/client.go @@ -209,7 +209,7 @@ 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 + retryClient.HTTPClient.Timeout = 90 * time.Second // timeout must be > 1m to accommodate long polling transport, ok := retryClient.HTTPClient.Transport.(*http.Transport) if !ok { From 8aa523c4532ee3e51cda5f1cb94327790b691f62 Mon Sep 17 00:00:00 2001 From: "jordan.brown" Date: Tue, 22 Oct 2024 12:28:29 -0700 Subject: [PATCH 2/2] Allow Actions Github Client HTTP timeout to be configurable --- github/actions/client.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/github/actions/client.go b/github/actions/client.go index 248c38ad27..e13bb376f9 100644 --- a/github/actions/client.go +++ b/github/actions/client.go @@ -13,6 +13,7 @@ import ( "math/rand" "net/http" "net/url" + "os" "strconv" "sync" "time" @@ -209,7 +210,17 @@ func NewClient(githubConfigURL string, creds *ActionsAuth, options ...ClientOpti retryClient.RetryMax = ac.retryMax retryClient.RetryWaitMax = ac.retryWaitMax - retryClient.HTTPClient.Timeout = 90 * time.Second // timeout must be > 1m to accommodate 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 {