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

cve_feed: manage http request and add request log #1407

Merged
merged 5 commits into from
Dec 13, 2024

Conversation

kledo-lyft
Copy link
Contributor

@kledo-lyft kledo-lyft commented Dec 13, 2024

NOTE: Turn on "Hide whitespaces" to review

Summary

We got some memory problem recently especially after NVD API becomes more unstable and retries are more often. This change attempts to reduce the memory leak while many requests are created, also logging the requests to help debug easier as there might be more improvements needed for this to work nicer.

  • Added a log statement to indicate when the NIST NVD API is being called, which includes the URL and parameters being used.
  • Wrap the requests.get call to use a context manager (with statement) to ensure the response is properly closed after use.

@kledo-lyft kledo-lyft force-pushed the cve-feed-memory-debug branch from 0367e6e to de77c8c Compare December 13, 2024 19:35
Copy link
Contributor

@cmm-lyft cmm-lyft left a comment

Choose a reason for hiding this comment

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

Could you please elaborate more how is this related to the memory usage spikes?

Comment on lines +98 to +99
logger.error(
f"Failed to get CVE data from NIST NVD API {res.status_code} : {res.text}",
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the spikes of memory are falling in this exception case.
Spikes are not raising an explicit HTTP exception, instead a runtime one (I guess, but I haven't find any logs from kibana / OpenSearch).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

discussing offline since it's related to Lyft

@kledo-lyft kledo-lyft enabled auto-merge (squash) December 13, 2024 22:18
@kledo-lyft kledo-lyft merged commit 8043cdd into master Dec 13, 2024
7 checks passed
@kledo-lyft kledo-lyft deleted the cve-feed-memory-debug branch December 13, 2024 22:20
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.

3 participants