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

TT-7248 Added backoff algorithm to pull the plugin bundles. #4513

Merged
Merged
Changes from 1 commit
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
Next Next commit
added backoff algorithm to pull the plugin bundles
sredxny committed Dec 8, 2022
commit e6cb952f55215ab6f517dd3a42ff2eba8c9c5946
14 changes: 13 additions & 1 deletion gateway/coprocess_bundle.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package gateway

import (
"github.com/cenk/backoff"
"path"
"time"

"github.com/sirupsen/logrus"

@@ -146,6 +148,7 @@ func (g *HTTPBundleGetter) Get() ([]byte, error) {
}
client := &http.Client{Transport: tr}

log.Infof("Attempting to download plugin bundle: %v", g.URL)
resp, err := client.Get(g.URL)
if err != nil {
return nil, err
@@ -259,7 +262,16 @@ func (gw *Gateway) fetchBundle(spec *APISpec) (Bundle, error) {
return bundle, err
}

bundleData, err := getter.Get()
var bundleData []byte
downloadBundle := func() error {
bundleData, err = getter.Get()
return err
}

exponentialBackoff := backoff.NewExponentialBackOff()
exponentialBackoff.Multiplier = 0.5
sredxny marked this conversation as resolved.
Show resolved Hide resolved
exponentialBackoff.MaxInterval = 5 * time.Second
err = backoff.Retry(downloadBundle, backoff.WithMaxRetries(exponentialBackoff, 4))

bundle.Name = spec.CustomMiddlewareBundle
bundle.Data = bundleData