-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add: Retrying for NVDApi #1070
Merged
Merged
Add: Retrying for NVDApi #1070
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Conventional Commits Report
🚀 Conventional commits found. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1070 +/- ##
==========================================
+ Coverage 89.91% 89.92% +0.01%
==========================================
Files 108 108
Lines 7178 7187 +9
Branches 812 815 +3
==========================================
+ Hits 6454 6463 +9
Misses 521 521
Partials 203 203 ☔ View full report in Codecov by Sentry. |
n-thumann
force-pushed
the
add_retry_nvd_api
branch
from
December 6, 2024 14:54
47233f9
to
f888815
Compare
n-thumann
force-pushed
the
add_retry_nvd_api
branch
from
December 12, 2024 10:02
27decd0
to
fd81880
Compare
y0urself
approved these changes
Dec 13, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
This PR adds the retrying of requests to
NVDApi
and the inheriting classes.Why
NVD is super unstable lately, so it's nearly impossible to retrieve a large response, because one of the HTTP requests will very likely fail. This caused vt-cve-library to be broken right now and cve-feeder to occasionally fail.
The current behavior on
main
is that the caller needs to handle those errors. However, the caller doesn't know which request (the offset of the paginated response) exactly failed, so send a new request starting from failed requests offset.One option would be to somehow pass this offset to the caller, however I opted for the approach to handle retries directly inside Pontos, just like rate-limiting also is for a more out-of-the-box developer experience.
This implementation is backwards-compatible and assumes one attempt, if not specified otherwise.
If
attempts
is greater than1
and there is a server-side (HTTP 5xx) error in the response, the request will be retried after a delay of 2 seconds, exponentially backing off.In my tests for vt-cve-library I was finally able to request data from NVD again, which failed after a few minutes before this change.
References
Jira: https://jira.greenbone.net/browse/VTA-630
Checklist