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

Make control client retry able in e2e tests #2601

Merged
merged 7 commits into from
Oct 18, 2024
Merged
Changes from 2 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
31 changes: 31 additions & 0 deletions tools/integration_tests/util/client/control_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,45 @@ import (
"context"
"fmt"
"log"
"reflect"
"strings"
"time"

control "cloud.google.com/go/storage/control/apiv2"
"cloud.google.com/go/storage/control/apiv2/controlpb"
"github.com/googleapis/gax-go/v2"
"google.golang.org/grpc/codes"
)

func storageControlClientRetryOptions(clientConfig *control.StorageControlClient) []gax.CallOption {
return []gax.CallOption{
Tulsishah marked this conversation as resolved.
Show resolved Hide resolved
gax.WithTimeout(300000 * time.Millisecond),
gax.WithRetry(func() gax.Retryer {
return gax.OnCodes([]codes.Code{
codes.ResourceExhausted,
codes.Unavailable,
codes.DeadlineExceeded,
codes.Internal,
codes.Unknown,
}, gax.Backoff{
Max: 30 * time.Second,
Multiplier: 2,
})
}),
}
}

func CreateControlClient(ctx context.Context) (client *control.StorageControlClient, err error) {
client, err = control.NewStorageControlClient(ctx)
opts := &control.StorageControlCallOptions{}

// Loop over all fields in the struct and assign retry options
v := reflect.ValueOf(opts).Elem()
for i := 0; i < v.NumField(); i++ {
field := v.Field(i)
field.Set(reflect.ValueOf(storageControlClientRetryOptions(client)))
}

if err != nil {
return nil, fmt.Errorf("control.NewStorageControlClient: #{err}")
}
Expand Down
Loading