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

compare: read data before file closes #3199

Merged
merged 1 commit into from
May 9, 2023

Conversation

deitch
Copy link
Contributor

@deitch deitch commented May 9, 2023

compare-sources-sbom was returning a handle to the file inside the tar reader, but returning from a function with a defer.Close() set. That caused the tar or tgz file to close before or while reading, leading to the error:

2023/05/09 00:02:14 Error parsing CSV file: error reading CSV file: read /home/runner/work/eve/eve/dist/amd64/0.0.0-master-32ca7d4e/collected_sources.tar.gz: file already closed

We didn't catch it before because it was intermittent. The whole CSV manifest to be read is ~56KB. That meant that the caller could actually read the file before the closing function (and underlying OS) might have read it. Hence, sometimes it worked, and we got (un)lucky when testing it earlier that it worked.

This fixes it by reading the whole small manifest into memory before returning.

cc @yash-zededa @eriknordmark

Signed-off-by: Avi Deitcher <avi@deitcher.net>
@deitch deitch requested review from eriknordmark and rvs as code owners May 9, 2023 07:02
Copy link
Contributor

@eriknordmark eriknordmark left a comment

Choose a reason for hiding this comment

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

Ok

@eriknordmark eriknordmark merged commit 54e4b41 into lf-edge:master May 9, 2023
@deitch deitch deleted the collect-sources-closed-file branch May 9, 2023 14:13
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