From 1260f551986b235c49a649dcdd374d21905be56f Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Wed, 23 Jul 2014 13:02:20 -0700 Subject: change file_staging_uses_destdir default to true --- CHANGELOG.md | 1 + RELEASE_NOTES.md | 9 +++++++++ lib/chef/config.rb | 2 +- lib/chef/file_content_management/tempfile.rb | 9 ++++++++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e38c8160b1..81b7ec01e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ * [**Xabier de Zuazo**](https://github.com/zuazo): Remove the unused StreamingCookbookUploader class (CHEF-4586) +* set file_stating_uses_destdir config option default to true (CHEF-5040) * remove dependency on rest-client gem * Add method shell_out_with_systems_locale to ShellOut. * Fix knife cookbook site share on windows (CHEF-4994) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index e550382238..16bd09b67e 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,14 @@ # Chef Client Release Notes: +## Changed file_staging_uses_destdir Config default to True + +Staging into the system's tempdir (usually /tmp or /var/tmp) rather than the destination directory can +cause issues with permissions or available space. It can also become problematic when doing cross-devices +renames which turn move operations into copy operations (using mv uses a new inode on Unix which avoids +ETXTBSY exceptions, while cp reuses the inode and can raise that error). Staging the tempfile for the +Chef file providers into the destination directory solve these problems for users. Windows ACLs on the +directory will also be inherited correctly. + ## Removed Rest-Client dependency - cookbooks that previously were able to use rest-client directly will now need to install it via `chef_gem "rest-client"`. diff --git a/lib/chef/config.rb b/lib/chef/config.rb index 65952b8cf7..929138488c 100644 --- a/lib/chef/config.rb +++ b/lib/chef/config.rb @@ -567,7 +567,7 @@ class Chef # If false file staging is will be done via tempfiles that are # created under ENV['TMP'] otherwise tempfiles will be created in # the directory that files are going to reside. - default :file_staging_uses_destdir, false + default :file_staging_uses_destdir, true # Exit if another run is in progress and the chef-client is unable to # get the lock before time expires. If nil, no timeout is enforced. (Exits diff --git a/lib/chef/file_content_management/tempfile.rb b/lib/chef/file_content_management/tempfile.rb index 0bb7f3a6fa..61a5ce2a7c 100644 --- a/lib/chef/file_content_management/tempfile.rb +++ b/lib/chef/file_content_management/tempfile.rb @@ -54,7 +54,14 @@ class Chef end def tempfile_dirname - Chef::Config[:file_staging_uses_destdir] ? ::File.dirname(@new_resource.path) : Dir::tmpdir + # in why-run mode we need to create a Tempfile to compare against, which we will never + # wind up deploying, but our enclosing directory for the destdir may not exist yet, so + # instead we can reliably always create a Tempfile to compare against in Dir::tmpdir + if Chef::Config[:file_staging_uses_destdir] && !Chef::Config[:why_run] + ::File.dirname(@new_resource.path) + else + Dir::tmpdir + end end end end -- cgit v1.2.1