-
Notifications
You must be signed in to change notification settings - Fork 12
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
Feat/Retry updating WSO2 api definitions while it is outdated #119
base: main
Are you sure you want to change the base?
Conversation
createAPIDef(wso2APIM, 'xxx', wso2APIM.apidefs[0]) | ||
).rejects.toThrow(); | ||
).rejects.toBeUndefined(); |
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.
The createAPIDef()
is not throwing the faulty error, is it expected?
|
||
expect(createAPIDef(wso2APIM, 'xxx', wso2APIM.apidefs[0])).rejects.toThrow(); | ||
await expect(createAPIDef(wso2APIM, 'xxx', wso2APIM.apidefs[0])).rejects.toBeUndefined(); |
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.
The createAPIDef()
is not throwing the faulty error, is it expected?
utils.renderError(err); | ||
throw err; |
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.
It was not throwing the error.
I believe we should throw it, right?
); | ||
} | ||
// ? seconds sleeping on each retry: 2, 4, 8, 16, 32, 64 | ||
await retryWithExponentialBackoff(({ attempt }) => deployApiDefAndUpsertSwagger(wso2APIM, api, apiDefs[i], attempt), { |
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.
question: should we add a log here on every fail/retry? to help us understand possible errors in the future?
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.
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #119 +/- ##
==========================================
+ Coverage 81.64% 89.24% +7.59%
==========================================
Files 3 4 +1
Lines 594 651 +57
Branches 74 81 +7
==========================================
+ Hits 485 581 +96
+ Misses 95 56 -39
Partials 14 14 ☔ View full report in Codecov by Sentry. |
Description
This is a follow-up of the discussion from pull request #114
It also fixes the #99
Issue
In some complex/distributed WSO2 setups it may take a while to synchronize the API definitions. When upserting the swagger right after the API def update, it will override the common data between them (e.g., CORS Headers) with the outdated API definitions.
Proposal
Creates an exponential backoff retry to keep retrying to update the WSO2 API definitions while it differs from what we expect.
it starts executing without delay, as it fails, we start sleeping for 2 seconds, then 4s, 8s, 16s, 32s, and finally 64 seconds.
Checklist
*.spec.js
)