-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
TT-7248 Added backoff algorithm to pull the plugin bundles. #4513
Conversation
API tests result: success ✅ |
💥 CI tests failed 🙈git-stateall ok Please look at the run or in the Checks tab. |
API tests result: success ✅ |
💥 CI tests failed 🙈git-statediff --git a/gateway/coprocess_bundle_test.go b/gateway/coprocess_bundle_test.go
index 53f65df..a82dfe1 100644
--- a/gateway/coprocess_bundle_test.go
+++ b/gateway/coprocess_bundle_test.go
@@ -11,9 +11,10 @@ import (
"runtime"
"testing"
+ "github.com/stretchr/testify/assert"
+
"github.com/TykTechnologies/tyk/config"
"github.com/TykTechnologies/tyk/test"
- "github.com/stretchr/testify/assert"
)
var (
Please look at the run or in the Checks tab. |
API tests result: success ✅ |
API tests result: success ✅ |
💥 CI tests failed 🙈git-statediff --git a/gateway/coprocess_bundle_test.go b/gateway/coprocess_bundle_test.go
index 53f65df..a82dfe1 100644
--- a/gateway/coprocess_bundle_test.go
+++ b/gateway/coprocess_bundle_test.go
@@ -11,9 +11,10 @@ import (
"runtime"
"testing"
+ "github.com/stretchr/testify/assert"
+
"github.com/TykTechnologies/tyk/config"
"github.com/TykTechnologies/tyk/test"
- "github.com/stretchr/testify/assert"
)
var (
Please look at the run or in the Checks tab. |
API tests result: success ✅ |
gateway/api_definition.go
Outdated
if def.CustomMiddlewareBundle != "" { | ||
wg.Add(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lonelycode do you think we need this or just handle all the apis in the same way? The reason to do it in this way is to avoid the gateway to spawn a lot of goroutines, and instead only create an async job when the api to be loaded need to pull a bundle
gateway/api_definition.go
Outdated
func (a APIDefinitionLoader) prepareSpecs(apiDefs []nestedApiDefinition) []*APISpec { | ||
var specs []*APISpec | ||
|
||
var wg sync.WaitGroup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@buger I have something against waitgroups and it's that it can generate a lot of jobs at the same time without a limit. What about if we use a pool of workers? in this case, how many of them we should have? or it's too complex for this problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@titpetric awesome, that leads me to the questions: how many should load at the same time?
Kudos, SonarCloud Quality Gate passed! |
API tests result: success ✅ |
/release to release-4 |
Working on it! Note that it can take a few minutes. |
@sredxny Succesfully merged PR |
<!-- Provide a general summary of your changes in the Title above --> ## Description Currently if the gateway cannot pull a plugin bundle then it just throw error and continue processing the next api definition. In this PR was introduced a new behavior, the gateway will attempt to download the bundle, of it fails then it will try until 4 more times, the timeframe between one attempt and the other is defined by an exponential backoff described [here](https://pkg.go.dev/github.com/cenkalti/backoff#NewExponentialBackOff) ~~Now when an API will load a bundle, it's processed async so the loading of the other apis is not blocked by this one.~~ ## Related Issue https://tyktech.atlassian.net/browse/TT-7248 ## Motivation and Context Provide a better response when downloading the bundles fails for external causes ## How This Has Been Tested - Added unit test for backoff algorithm - in Dash+GW setup: created apis, one of them with bundle plugin...finally check that all the apis are reachable ## Screenshots (if appropriate) ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [ ] I ensured that the documentation is up to date - [ ] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why (cherry picked from commit 2230b14)
/release to release-4-lts |
Working on it! Note that it can take a few minutes. |
<!-- Provide a general summary of your changes in the Title above --> Currently if the gateway cannot pull a plugin bundle then it just throw error and continue processing the next api definition. In this PR was introduced a new behavior, the gateway will attempt to download the bundle, of it fails then it will try until 4 more times, the timeframe between one attempt and the other is defined by an exponential backoff described [here](https://pkg.go.dev/github.com/cenkalti/backoff#NewExponentialBackOff) ~~Now when an API will load a bundle, it's processed async so the loading of the other apis is not blocked by this one.~~ https://tyktech.atlassian.net/browse/TT-7248 Provide a better response when downloading the bundles fails for external causes - Added unit test for backoff algorithm - in Dash+GW setup: created apis, one of them with bundle plugin...finally check that all the apis are reachable <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [ ] I ensured that the documentation is up to date - [ ] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why (cherry picked from commit 2230b14)
@sredxny Succesfully merged PR |
/release to release-4.3 |
API tests result: success ✅ DescriptionCurrently if the gateway cannot pull a plugin bundle then it just throw
Related Issuehttps://tyktech.atlassian.net/browse/TT-7248 Motivation and ContextProvide a better response when downloading the bundles fails for How This Has Been Tested
Screenshots (if appropriate)Types of changes
Checklist
|
/release to release-4.3 |
Working on it! Note that it can take a few minutes. |
@sredxny Succesfully merged PR |
<!-- Provide a general summary of your changes in the Title above --> ## Description Currently if the gateway cannot pull a plugin bundle then it just throw error and continue processing the next api definition. In this PR was introduced a new behavior, the gateway will attempt to download the bundle, of it fails then it will try until 4 more times, the timeframe between one attempt and the other is defined by an exponential backoff described [here](https://pkg.go.dev/github.com/cenkalti/backoff#NewExponentialBackOff) ~~Now when an API will load a bundle, it's processed async so the loading of the other apis is not blocked by this one.~~ ## Related Issue https://tyktech.atlassian.net/browse/TT-7248 ## Motivation and Context Provide a better response when downloading the bundles fails for external causes ## How This Has Been Tested - Added unit test for backoff algorithm - in Dash+GW setup: created apis, one of them with bundle plugin...finally check that all the apis are reachable ## Screenshots (if appropriate) ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [ ] I ensured that the documentation is up to date - [ ] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why (cherry picked from commit 2230b14)
…lugin bundles. (#4513) (#4531) TT-7248 Added backoff algorithm to pull the plugin bundles. (#4513) <!-- Provide a general summary of your changes in the Title above --> ## Description Currently if the gateway cannot pull a plugin bundle then it just throw error and continue processing the next api definition. In this PR was introduced a new behavior, the gateway will attempt to download the bundle, of it fails then it will try until 4 more times, the timeframe between one attempt and the other is defined by an exponential backoff described [here](https://pkg.go.dev/github.com/cenkalti/backoff#NewExponentialBackOff) ~~Now when an API will load a bundle, it's processed async so the loading of the other apis is not blocked by this one.~~ ## Related Issue https://tyktech.atlassian.net/browse/TT-7248 ## Motivation and Context Provide a better response when downloading the bundles fails for external causes ## How This Has Been Tested - Added unit test for backoff algorithm - in Dash+GW setup: created apis, one of them with bundle plugin...finally check that all the apis are reachable ## Screenshots (if appropriate) ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [ ] I ensured that the documentation is up to date - [ ] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why Co-authored-by: Sredny M <sredny.buitrago@gmail.com>
…gin bundles. (#4513) (#4529) TT-7248 Added backoff algorithm to pull the plugin bundles. (#4513) <!-- Provide a general summary of your changes in the Title above --> ## Description Currently if the gateway cannot pull a plugin bundle then it just throw error and continue processing the next api definition. In this PR was introduced a new behavior, the gateway will attempt to download the bundle, of it fails then it will try until 4 more times, the timeframe between one attempt and the other is defined by an exponential backoff described [here](https://pkg.go.dev/github.com/cenkalti/backoff#NewExponentialBackOff) ~~Now when an API will load a bundle, it's processed async so the loading of the other apis is not blocked by this one.~~ ## Related Issue https://tyktech.atlassian.net/browse/TT-7248 ## Motivation and Context Provide a better response when downloading the bundles fails for external causes ## How This Has Been Tested - Added unit test for backoff algorithm - in Dash+GW setup: created apis, one of them with bundle plugin...finally check that all the apis are reachable ## Screenshots (if appropriate) ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [ ] I ensured that the documentation is up to date - [ ] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why Co-authored-by: Sredny M <sredny.buitrago@gmail.com>
/release to release-4-lts |
Working on it! Note that it can take a few minutes. |
<!-- Provide a general summary of your changes in the Title above --> Currently if the gateway cannot pull a plugin bundle then it just throw error and continue processing the next api definition. In this PR was introduced a new behavior, the gateway will attempt to download the bundle, of it fails then it will try until 4 more times, the timeframe between one attempt and the other is defined by an exponential backoff described [here](https://pkg.go.dev/github.com/cenkalti/backoff#NewExponentialBackOff) ~~Now when an API will load a bundle, it's processed async so the loading of the other apis is not blocked by this one.~~ https://tyktech.atlassian.net/browse/TT-7248 Provide a better response when downloading the bundles fails for external causes - Added unit test for backoff algorithm - in Dash+GW setup: created apis, one of them with bundle plugin...finally check that all the apis are reachable <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [ ] I ensured that the documentation is up to date - [ ] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why (cherry picked from commit 2230b14)
@sredxny Succesfully merged PR |
… plugin bundles. (#4513) (#4537) TT-7248 Added backoff algorithm to pull the plugin bundles. (#4513) <!-- Provide a general summary of your changes in the Title above --> ## Description Currently if the gateway cannot pull a plugin bundle then it just throw error and continue processing the next api definition. In this PR was introduced a new behavior, the gateway will attempt to download the bundle, of it fails then it will try until 4 more times, the timeframe between one attempt and the other is defined by an exponential backoff described [here](https://pkg.go.dev/github.com/cenkalti/backoff#NewExponentialBackOff) ~~Now when an API will load a bundle, it's processed async so the loading of the other apis is not blocked by this one.~~ ## Related Issue https://tyktech.atlassian.net/browse/TT-7248 ## Motivation and Context Provide a better response when downloading the bundles fails for external causes ## How This Has Been Tested - Added unit test for backoff algorithm - in Dash+GW setup: created apis, one of them with bundle plugin...finally check that all the apis are reachable ## Screenshots (if appropriate) ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [ ] I ensured that the documentation is up to date - [ ] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why Co-authored-by: Sredny M <sredny.buitrago@gmail.com>
Description
Currently if the gateway cannot pull a plugin bundle then it just throw error and continue processing the next api definition. In this PR was introduced a new behavior, the gateway will attempt to download the bundle, of it fails then it will try until 4 more times, the timeframe between one attempt and the other is defined by an exponential backoff described here
Now when an API will load a bundle, it's processed async so the loading of the other apis is not blocked by this one.Related Issue
https://tyktech.atlassian.net/browse/TT-7248
Motivation and Context
Provide a better response when downloading the bundles fails for external causes
How This Has Been Tested
Screenshots (if appropriate)
Types of changes
Checklist