Skip to content

Commit d32102b

Browse files
committed
retry proto registration
1 parent 9a9e821 commit d32102b

File tree

5 files changed

+32
-15
lines changed

5 files changed

+32
-15
lines changed

.github/workflows/framework-dockercompose-tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: TestChipIngressSmoke
1919
config: smoke_chip.toml
2020
count: 1
21-
timeout: 10m
21+
timeout: 3m
2222
name: ${{ matrix.test.name }}
2323
steps:
2424
- name: Checkout repo
@@ -71,6 +71,7 @@ jobs:
7171
env:
7272
CTF_CONFIGS: ${{ matrix.test.config }}
7373
CHIP_INGRESS_IMAGE: ${{ secrets.AWS_ACCOUNT_ID_PROD }}.dkr.ecr.us-west-2.amazonaws.com/atlas-chip-ingress:qa-latest
74+
CTF_LOG_LEVEL: debug
7475
run: |
7576
go test -timeout ${{ matrix.test.timeout }} -v -count ${{ matrix.test.count }} -run ${{ matrix.test.name }}
7677

framework/components/dockercompose/chip_ingress_set/chip_ingress.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ func New(in *Input) (*Output, error) {
128128
wait.NewHostPortStrategy(DEFAULT_RED_PANDA_SCHEMA_REGISTRY_PORT).WithPollInterval(100*time.Millisecond),
129129
wait.NewHostPortStrategy(DEFAULT_RED_PANDA_KAFKA_PORT).WithPollInterval(100*time.Millisecond),
130130
wait.ForHTTP("/v1/status/ready").WithPort("9644"), // admin API port
131+
wait.ForHTTP("/status/ready").WithPort(DEFAULT_RED_PANDA_SCHEMA_REGISTRY_PORT).WithPollInterval(100*time.Millisecond),
131132
).WithDeadline(2*time.Minute),
132133
).WaitForService(DEFAULT_RED_PANDA_CONSOLE_SERVICE_NAME,
133134
wait.ForAll(

framework/components/dockercompose/chip_ingress_set/protos.go

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import (
1111
"path/filepath"
1212
"regexp"
1313
"strings"
14+
"time"
1415

16+
"github.com/avast/retry-go/v4"
1517
"github.com/google/go-github/v72/github"
1618
"github.com/pkg/errors"
1719
"github.com/smartcontractkit/chainlink-testing-framework/framework"
@@ -510,23 +512,33 @@ func registerSingleProto(
510512
}
511513

512514
url := fmt.Sprintf("%s/subjects/%s/versions", registryURL, subject)
513-
// Force IPv4 to avoid Docker IPv6 port forwarding issues
514-
url = strings.Replace(url, "localhost", "127.0.0.1", 1)
515-
framework.L.Debug().Msgf("Registering schema to URL: %s", url)
515+
maxAttempts := uint(10)
516516

517-
resp, respErr := http.Post(url, "application/vnd.schemaregistry.v1+json", bytes.NewReader(payload))
518-
if respErr != nil {
519-
return 0, errors.Wrap(respErr, "failed to post to schema registry")
520-
}
521-
defer resp.Body.Close()
517+
var resp *http.Response
518+
retry.Do(func() error {
519+
var respErr error
520+
resp, respErr = http.Post(url, "application/vnd.schemaregistry.v1+json", bytes.NewReader(payload))
521+
if respErr != nil {
522+
return errors.Wrap(respErr, "failed to post to schema registry")
523+
}
522524

523-
if resp.StatusCode >= 300 {
524-
data, dataErr := io.ReadAll(resp.Body)
525-
if dataErr != nil {
526-
return 0, errors.Wrap(dataErr, "failed to read response body")
525+
if resp.StatusCode >= 300 {
526+
data, dataErr := io.ReadAll(resp.Body)
527+
if dataErr != nil {
528+
return errors.Wrap(dataErr, "failed to read response body")
529+
}
530+
return fmt.Errorf("schema registry error (%d): %s", resp.StatusCode, data)
527531
}
528-
return 0, fmt.Errorf("schema registry error (%d): %s", resp.StatusCode, data)
529-
}
532+
533+
return nil
534+
}, retry.Attempts(maxAttempts), retry.Delay(100*time.Millisecond), retry.DelayType(retry.BackOffDelay), retry.OnRetry(func(n uint, err error) {
535+
framework.L.Debug().Str("attempt/max", fmt.Sprintf("%d/%d", n, maxAttempts)).Msgf("Retrying to register schema %s: %v", subject, err)
536+
}), retry.RetryIf(func(err error) bool {
537+
// we don't want to retry all errors, because some of them are are expected (e.g. missing dependencies)
538+
// and will be handled by higher-level code
539+
return strings.Contains(err.Error(), "connection reset by peer")
540+
}))
541+
defer resp.Body.Close()
530542

531543
var result struct {
532544
ID int `json:"id"`

framework/components/dockercompose/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ require (
2626
github.com/Microsoft/go-winio v0.6.2 // indirect
2727
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
2828
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
29+
github.com/avast/retry-go/v4 v4.6.1 // indirect
2930
github.com/aws/aws-sdk-go-v2 v1.31.0 // indirect
3031
github.com/aws/aws-sdk-go-v2/config v1.27.39 // indirect
3132
github.com/aws/aws-sdk-go-v2/credentials v1.17.37 // indirect

framework/components/dockercompose/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew
4040
github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
4141
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
4242
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
43+
github.com/avast/retry-go/v4 v4.6.1 h1:VkOLRubHdisGrHnTu89g08aQEWEgRU7LVEop3GbIcMk=
44+
github.com/avast/retry-go/v4 v4.6.1/go.mod h1:V6oF8njAwxJ5gRo1Q7Cxab24xs5NCWZBeaHHBklR8mA=
4345
github.com/aws/aws-sdk-go-v2 v1.31.0 h1:3V05LbxTSItI5kUqNwhJrrrY1BAXxXt0sN0l72QmG5U=
4446
github.com/aws/aws-sdk-go-v2 v1.31.0/go.mod h1:ztolYtaEUtdpf9Wftr31CJfLVjOnD/CVRkKOOYgF8hA=
4547
github.com/aws/aws-sdk-go-v2/config v1.27.39 h1:FCylu78eTGzW1ynHcongXK9YHtoXD5AiiUqq3YfJYjU=

0 commit comments

Comments
 (0)