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

Feat/Retry updating WSO2 api definitions while it is outdated #119

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

MarcioMeier
Copy link
Collaborator

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

  • Updated unit tests (*.spec.js)
  • Updated e2e tests (here)
  • Updated documentation (here)

@MarcioMeier MarcioMeier self-assigned this Feb 2, 2024
createAPIDef(wso2APIM, 'xxx', wso2APIM.apidefs[0])
).rejects.toThrow();
).rejects.toBeUndefined();
Copy link
Collaborator Author

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();
Copy link
Collaborator Author

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;
Copy link
Collaborator Author

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), {
Copy link
Collaborator Author

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can realize that it was retried because the update message is repeated...
Screenshot 2024-02-02 at 14 05 53

@codecov-commenter
Copy link

codecov-commenter commented Feb 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.24%. Comparing base (e4bb55b) to head (ba5a73b).

❗ 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.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants