-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Optimize sealed secret scanning to avoid full file reads #11647
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
Optimize sealed secret scanning to avoid full file reads #11647
Conversation
bb0eeb9
to
ab643d1
Compare
Thx for your contribution to refactor this code. Could you please correct the commit message and commit title following our community guidence and example. Please see patch format and examples |
ab643d1
to
e4a0319
Compare
Commit message updated as per contribution guidelines. PTAL, thanks! |
Hi @Apokleos, Could you please add |
e4a0319
to
c3a89cf
Compare
This optimization looks promising, It definitely seems like it could lead to some performance improvements. |
Hi @Apokleos, this PR is ready for review. Could you please help add some reviewers? Thx! |
@@ -262,6 +264,14 @@ pub async fn unseal_file(path: &str) -> Result<()> { | |||
Ok(()) | |||
} | |||
|
|||
fn content_starts_with_prefix(path: &Path, prefix: &str) -> std::io::Result<bool> { |
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.
Why not rewite the function with async
?
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.
Good point, updated to async
now. Thx.
c3a89cf
to
5e3baa3
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
Thanks @Park-Jiyeonn
Hi @Apokleos, some CI checks are still failing — is there anything else I need to do on my side? Thx! |
Read only the sealed secret prefix instead of the whole file. Improves performance and reduces memory usage in I/O-heavy environments. Fixes: kata-containers#11643 Signed-off-by: Park.Jiyeon <jiyeonnn2@icloud.com>
5041123
to
2f50c85
Compare
Hi @Apokleos, some CI checks are still failing — Could you please help me take a look when you have a moment? Your guidance would be really appreciated. Thx in advance!! |
The only required test still failing was due to a sporadic I've seen some times already. I believe this is good to merge. |
Fixes: #11643
This PR optimizes the sealed secret scanning logic to avoid unnecessary full file reads, which can cause performance and reliability issues in certain environments.
Optimization
Instead of reading the entire file, we now:
N
bytes (N = SEALED_SECRET_PREFIX.len()
).This avoids expensive I/O and reduces memory usage, while still preserving the intended functionality.