-
Notifications
You must be signed in to change notification settings - Fork 288
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
Handle premature deletion of temporary tar files #144
Conversation
Specs are failing for the same reason I found in #140: Rubygems is defaulting to Rspec 3 now. So need to pin to Rspec <3.0.0. |
The other option would be pinning to RSpec |
@tylerhunt that sounds like a good approach. Would you like to open as a separate pull? |
Nmind, you already did! 😄 |
For additional context, I've verified that the original error happens fairly consistently in Ruby 2.1.1 and 2.1.2, but not in 2.0.0. I'm assuming something changed in the GC behavior starting in Ruby 2.1. |
It only fails under Ruby 2.1, so add 2.1 to Travis.
Thanks, @markkendall. Added a spec that fails under Ruby 2.1. |
Interestingly, here, we're opening the Also, it appears when you run |
I tried getting rid of the secondary file altogether, but the Archive::Tar::Minitar.pack('.', tempfile) And that I also tried doing |
Interesting. So, it seems from the docs that The garbage collector must be removing it since it doesn't know the file is still open. It seems the |
@tlunter Do you mean |
@tylerhunt do you know what the build failures here are due to yet? |
@tylerhunt, sorry. I did mean |
@bfulton Pretty sure they're all related to RSpec 3. I'll rebase this branch once #146 has been merged. Ahh, I see what you're saying now, @tlunter. Yes, that may be a possibility. Here are a couple possible ways this could be resolved:
|
Thanks @tylerhunt and @tlunter. This is closed through #147. |
This fixes the error reported in #133, in which creating an image could result in an error like:
In this case, the image is built fine, but by the time
Container#build_from_dir
reaches theensure
block where the temporary Tar file is closed, the temporary file has already been removed. While I was unable to produce a failing test case, this was a reproducible issue in my own app, and this fix appears to resolve it.I believe the issue is that Ruby's automatic unlinking of the temporary file is kicking in at some point while the build is in progress (maybe during GC, though
GC.start
alone didn't seem to trigger it my test), since there is no longer a reference to theTempfile
instance after theUtil#create_dir_tar
method has returned.