-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
download: Fix saving OCI bundles on disk #6945
download: Fix saving OCI bundles on disk #6945
Conversation
7b41d70
to
6973d99
Compare
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.
Thanks @Sergey-Kizimov! The fix looks fine. If you could add some unit tests that would be great.
Hi there! And thanks for contributing to OPA! Can you please add a test to verify the fix? |
Ok, will add. |
40e84f2
to
a2068f3
Compare
I added unit test |
download/oci_download_test.go
Outdated
t.Fatal("expected bundle reader to be non-nil") | ||
} | ||
|
||
if buf.Len() == 0 { |
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.
We should probably check u1.Size == 0
here. Also for completeness can we do something like this test.
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.
I see, looks like another bug - the Size is not being filled in the downloaderResponse.
Let me fix that
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.
I've checked code in oci_download
and download
files, and oci_download
has several dependencies with the download
package, Update
struct as an example, not sure how best to proceed here.
Just leave count
in download
then?
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.
Pushed changes
04cdd51
to
b36a332
Compare
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
This commit fixes an issue related to zero-sized bundles being saved to disk, which can cause OPA to fail to start if a remote OCI repository is unavailable. Fixes: open-policy-agent#6939 Signed-off-by: Sergey-Kizimov <serget.kizimov@hiya.com> Signed-off-by: Sergey-Kizimov <sergey.kizimov@hiya.com>
Signed-off-by: Sergey-Kizimov <sergey.kizimov@hiya.com>
Signed-off-by: Sergey-Kizimov <sergey.kizimov@hiya.com>
b36a332
to
8b9cad3
Compare
This commit fixes an issue related to zero-sized bundles being saved to disk, which can cause OPA to fail to start if a remote OCI repository is unavailable.
Fixes: #6939