nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: googleapis/google-cloud-go
Pull request #6976 (2022-11-01 21:39:44)

feat(bigquery): widen retry predicate
This PR adds 500,504 http response codes for the default retry predicate on unary retries.

This doesn't introduce job-level retries (jobs must be recreated wholly, they can't be effectively restarted), so the primary risk of this change is terminal job state propagating into the HTTP response code of one of the polling methods (e.g. job.getQueryResults, jobs.get, etc).  In this situation, job execution may appear to hang indefinitely or until context cancellation/expiry.

Related: https://github.com/googleapis/google-cloud-go/issues/5248

shollyman: > LGTM. But I think we might need to start some design doc or discussion around making the retry logic more configurable. Do we know of other client libraries that allow that to take some inspiration ?

There's some hooks we can consider such as https://pkg.go.dev/github.com/googleapis/gax-go/v2#WithRetry

Storage rolled their own client-level settings: https://pkg.go.dev/cloud.google.com/go/storage#Client.SetRetry

Patch:
diff --git a/bigquery/bigquery.go b/bigquery/bigquery.go
index 9b47357222..8bb92ba683 100644
--- a/bigquery/bigquery.go
+++ b/bigquery/bigquery.go
@@ -203,12 +203,16 @@ func runWithRetryExplicit(ctx context.Context, call func() error, allowedReasons
 var (
 	defaultRetryReasons = []string{"backendError", "rateLimitExceeded"}
 	jobRetryReasons     = []string{"backendError", "rateLimitExceeded", "internalError"}
+	retry5xxCodes       = []int{
+		http.StatusInternalServerError,
+		http.StatusBadGateway,
+		http.StatusServiceUnavailable,
+		http.StatusGatewayTimeout,
+	}
 )
 
-// This is the correct definition of retryable according to the BigQuery team. It
-// also considers 502 ("Bad Gateway") and 503 ("Service Unavailable") errors
-// retryable; these are returned by systems between the client and the BigQuery
-// service.
+// retryableError is the unary retry predicate for this library.  In addition to structured error
+// reasons, it specifies some HTTP codes (500, 502, 503, 504) and network/transport reasons.
 func retryableError(err error, allowedReasons []string) bool {
 	if err == nil {
 		return false
@@ -237,8 +241,10 @@ func retryableError(err error, allowedReasons []string) bool {
 				}
 			}
 		}
-		if e.Code == http.StatusServiceUnavailable || e.Code == http.StatusBadGateway {
-			return true
+		for _, code := range retry5xxCodes {
+			if e.Code == code {
+				return true
+			}
 		}
 	case *url.Error:
 		retryable := []string{"connection refused", "connection reset"}


Test patch:
diff --git a/bigquery/bigquery_test.go b/bigquery/bigquery_test.go
index c5207c0ab1..f1fd24745a 100644
--- a/bigquery/bigquery_test.go
+++ b/bigquery/bigquery_test.go
@@ -86,7 +86,7 @@ func TestRetryableErrors(t *testing.T) {
 			&googleapi.Error{
 				Code: http.StatusInternalServerError,
 			},
-			false,
+			true,
 		},
 		{
 			"internal w/backend reason",
Repository: aws/amazon-ecs-cli-v2
Pull request #315 (2019-11-09 02:33:51)

Move pipeline files into stack pkg
<!-- Provide summary of changes -->

<!-- Issue number, if available. E.g. "Fixes #31", "Addresses #42, 77" -->

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.



Patch:
diff --git a/internal/pkg/deploy/cloudformation/pipeline.go b/internal/pkg/deploy/cloudformation/stack/pipeline.go
similarity index 98%
rename from internal/pkg/deploy/cloudformation/pipeline.go
rename to internal/pkg/deploy/cloudformation/stack/pipeline.go
index 1da1b568..2647cf93 100644
--- a/internal/pkg/deploy/cloudformation/pipeline.go
+++ b/internal/pkg/deploy/cloudformation/stack/pipeline.go
@@ -1,7 +1,7 @@
 // Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 // SPDX-License-Identifier: Apache-2.0
 
-package cloudformation
+package stack
 
 import (
 	"bytes"
@@ -36,7 +36,7 @@ func (p *pipelineStackConfig) Template() (string, error) {
 	if err != nil {
 		return "", &ErrTemplateNotFound{templateLocation: pipelineCfnTemplatePath, parentErr: err}
 	}
-	
+
 	tpl, err := template.New("pipelineCfn").Parse(content)
 	if err != nil {
 		return "", fmt.Errorf("parse CloudFormation template for project %s, pipeline %s, error: %w",


Test patch:
diff --git a/internal/pkg/deploy/cloudformation/pipeline_test.go b/internal/pkg/deploy/cloudformation/stack/pipeline_test.go
similarity index 96%
rename from internal/pkg/deploy/cloudformation/pipeline_test.go
rename to internal/pkg/deploy/cloudformation/stack/pipeline_test.go
index 1e51414f..a1729b31 100644
--- a/internal/pkg/deploy/cloudformation/pipeline_test.go
+++ b/internal/pkg/deploy/cloudformation/stack/pipeline_test.go
@@ -1,7 +1,7 @@
 // Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 // SPDX-License-Identifier: Apache-2.0
 
-package cloudformation
+package stack
 
 import (
 	"fmt"
@@ -55,7 +55,7 @@ func TestPipelineStackName(t *testing.T) {
 }
 
 func TestPipelineTemplateRendering(t *testing.T) {
-	expectedTemplate, err := ioutil.ReadFile("./testdata/rendered_pipeline_cfn_template.yml")
+	expectedTemplate, err := ioutil.ReadFile("../testdata/rendered_pipeline_cfn_template.yml")
 	require.NoError(t, err, "expected template can not be read")
 
 	pipeline := newPipelineStackConfig(