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

twoliter: ensure krane tmpfile is deleted #420

Closed
wants to merge 1 commit into from

Conversation

cbgbt
Copy link
Contributor

@cbgbt cbgbt commented Dec 18, 2024

Issue number:

Closes #417

Change Description:
When using named tempfiles or tempdirs, the tempfile crate relies on Rust calling drop() in order to delete the created temporary files.

We were using a static reference to a tempfile of the krane binary, which is not guaranteed to drop when the program completes. This caused twoliter to leak somewhat large krane binary tempfiles.

This commit moves away from a static reference to the tempfile, instead improving ergonomics around ImageTool owning the tempfile reference. This allows the Rust compiler to more-reliably drop() the reference on exit.

Testing done:

  • Unit tests for drop behavior
  • Integration tests pass
  • Manual checks that practical twoliter executions do not leak files

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

When using named tempfiles or tempdirs, the `tempfile` crate relies on
Rust calling `drop()` in order to delete the created temporary files.

We were using a static reference to a tempfile of the krane binary,
which is not guaranteed to drop when the program completes. This caused
twoliter to leak somewhat large krane binary tempfiles.

This commit moves away from a static reference to the tempfile, instead
improving ergonomics around ImageTool owning the tempfile reference.
This allows the Rust compiler to more-reliably drop() the reference on
exit.
@cbgbt
Copy link
Contributor Author

cbgbt commented Dec 20, 2024

drop() isn't called on SIGTERM so this doesn't actually protect us in the common scenario that someone uses ctrl-c while twoliter is running.

I think the solution should be to unpack krane to a well-known location like we do for other tools. I'll take a look at that.

@cbgbt
Copy link
Contributor Author

cbgbt commented Dec 23, 2024

Closed in favor of #423

@cbgbt cbgbt closed this Dec 30, 2024
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.

krane tempfiles are not properly cleaned up
1 participant