-
Notifications
You must be signed in to change notification settings - Fork 214
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
Fix redhat import failure #418
Conversation
Introduced and used a helper function for retries on 5xx errors. This is important and some servers like bugzilla.redhat.com return 502 Proxy Error which was the cause of aboutcode-org#398 A ticket has been raised in RedHat here https://redhat.service-now.com/help?id=rh_ticket&table=sc_req_item&sys_id=278239541b1ba010477e43fccd4bcb4a Signed-off-by: Hritik Vijay <[email protected]>
This is mentioned in the NOTE of "2.1 List all CVRFs" of https://access.redhat.com/documentation/en-us/red_hat_security_data_api/1.0/html/red_hat_security_data_api/cvrf Such a case would lead to a crash before this commit. Eg: https://access.redhat.com/hydra/rest/securitydata/cvrf/RHSA-2005:835.json No cvrfdoc would be found in the statement value = rhsa_data["cvrfdoc"]["aggregate_severity"] Signed-off-by: Hritik Vijay <[email protected]>
This finally fixes aboutcode-org#398 Signed-off-by: Hritik Vijay <[email protected]>
Previous commits replace the usage of requests.get() altogether with a custom requests_session which provides better 5xx error handling. It is now required to mock that object in this test. IMHO it would make more sense to update this test altogether to use the real endpoints against some real data. Signed-off-by: Hritik Vijay <[email protected]>
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.
LGTM, though I hate we need to do this low level requests things ;)
@@ -79,3 +80,21 @@ def create_etag(data_src, url, etag_key): | |||
|
|||
|
|||
is_cve = re.compile(r"CVE-\d+-\d+", re.IGNORECASE).match | |||
|
|||
|
|||
def requests_with_5xx_retry(max_retries=5, backoff_factor=0.5): |
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.
You said there were 104 errors, how are they addressed ?
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.
104 came after retrying with short delays for multiple times. I increased the backoff_factor
to 1 in the redhat importer.
@sbs2001 Perhaps we would be able to revert back after redhat fixes the problem on their side. Until then, this is what we got. |
This fixes #398.
This PR is mainly comprises of following two commits.
requests_with_5xx_retry: Retry on 5xx errors
Introduced and used a helper function for retries on 5xx errors. This is
important and some servers like bugzilla.redhat.com return 502 Proxy Error
which was the cause of #398
A ticket has been raised in RedHat here https://redhat.service-now.com/help?id=rh_ticket&table=sc_req_item&sys_id=278239541b1ba010477e43fccd4bcb4a
Here is the response from [email protected]
Not all RHSA errata have a CVRF document
This is mentioned in the NOTE of "2.1 List all CVRFs" of
https://access.redhat.com/documentation/en-us/red_hat_security_data_api/1.0/html/red_hat_security_data_api/cvrf
Such a case would lead to a crash before this commit.
Eg: https://access.redhat.com/hydra/rest/securitydata/cvrf/RHSA-2005:835.json
No cvrfdoc would be found in the statement
value = rhsa_data["cvrfdoc"]["aggregate_severity"]