-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
cve_feed: Correct the retry and sleep time (#1410)
### Summary The [current code](https://github.com/cartography-cncf/cartography/blob/4d53bce6d9f3f6703b709b70071cbcc36820a5bb/cartography/intel/cve/feed.py#L73-L113) uses of variable `sleep_time` for both retries and sleep between requests. Furthermore, the `sleep_time` was not reset in the next request, meaning that if the first request increases it to 16 seconds, the second request will continue to take that up to every bigger number (the `retries` count is reset though which makes it worse). Two changes here: - The sleep between requests is set to be a dedicated variable `sleep_between_requests`. - I decided to rewrite the request retry logic more properly using HttpAdapter's retry policy. Unfortunately, I tried pretty hard to see if we can keep `test_call_cves_api_with_error` which tests the retry logic but it's not very feasible. Also it doesn't make a lot of sense to test something managed by the Session object itself. So I had to drop it. ### Testing I think existing integ test can confirm the code is still working. The retry change itself will need some manual review to see if it makes sense. --------- Signed-off-by: Khanh Le Do <kledo@lyft.com>
1 parent
0d02954
commit eddab71
Showing
3 changed files
with
98 additions
and
99 deletions.
There are no files selected for viewing
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
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
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