Chef

File specificity (preferred file) is broken by dotfiles

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 0.5.2
  • Fix Version/s: 0.7.6
  • Component/s: Chef Client, Chef Server
  • Labels:
    None
  • Environment:

    running against chef head 0.5.3

Description

bash-3.2# find .
.
./files
./files/default
./files/default/.vimrc
./recipes
./recipes/default.rb
bash-3.2# cat recipes/default.rb
remote_file "/tmp/vimrc" do
source ".vimrc"
owner "aj"
group "staff"
end

client stack:
[Tue, 03 Feb 2009 16:25:45 +1300] DEBUG: Processing remote_file[/tmp/vimrc]
[Tue, 03 Feb 2009 16:25:45 +1300] DEBUG: remote_file[/tmp/vimrc] using Chef::Provider::RemoteFile
[Tue, 03 Feb 2009 16:25:45 +1300] DEBUG: Checking remote_file[/tmp/vimrc] for changes
[Tue, 03 Feb 2009 16:25:45 +1300] DEBUG: Sending HTTP Request via GET to /cookbooks/testing/files?id=.vimrc&platform=mac_os_x&version=10.5.6&fqdn=123-100-101-20.maxnet.net.nz&checksum=8b9cc46b38e14b05362b1acbd165d61480e1d9da521cfad889bee437a225c7e3
[Tue, 03 Feb 2009 16:25:45 +1300] DEBUG: /cookbooks/testing/files?id=.vimrc&platform=mac_os_x&version=10.5.6&fqdn=123-100-101-20.maxnet.net.nz&checksum=8b9cc46b38e14b05362b1acbd165d61480e1d9da521cfad889bee437a225c7e3 30% done (880 of 2865)
[Tue, 03 Feb 2009 16:25:45 +1300] DEBUG: /cookbooks/testing/files?id=.vimrc&platform=mac_os_x&version=10.5.6&fqdn=123-100-101-20.maxnet.net.nz&checksum=8b9cc46b38e14b05362b1acbd165d61480e1d9da521cfad889bee437a225c7e3 66% done (1904 of 2865)
[Tue, 03 Feb 2009 16:25:45 +1300] DEBUG: /cookbooks/testing/files?id=.vimrc&platform=mac_os_x&version=10.5.6&fqdn=123-100-101-20.maxnet.net.nz&checksum=8b9cc46b38e14b05362b1acbd165d61480e1d9da521cfad889bee437a225c7e3 100% done (2865 of 2865)
[Tue, 03 Feb 2009 16:25:45 +1300] ERROR: remote_file[/tmp/vimrc] (/Library/Ruby/Gems/1.8/gems/chef-0.5.3/lib/chef/recipe.rb line 182) had an error:
404 "Not Found"

server stack:
merb : worker (port 4000) ~ Routed to: {"format"=>nil, "platform"=>"mac_os_x", "cookbook_id"=>"testing", "fqdn"=>"123-100-101-20.maxnet.net.nz", "action"=>"index", "id"=>".vimrc", "controller"=>"cookbook_files", "version"=>"10.5.6", "checksum"=>"8b9cc46b38e14b05362b1acbd165d61480e1d9da521cfad889bee437a225c7e3"}
merb : worker (port 4000) ~ Params: {"format"=>nil, "platform"=>"mac_os_x", "cookbook_id"=>"testing", "fqdn"=>"123-100-101-20.maxnet.net.nz", "action"=>"index", "id"=>".vimrc", "controller"=>"cookbook_files", "version"=>"10.5.6", "checksum"=>"8b9cc46b38e14b05362b1acbd165d61480e1d9da521cfad889bee437a225c7e3"}
merb : worker (port 4000) ~ Cannot find a suitable file! - (Merb::ControllerExceptions::NotFound)
/Library/Ruby/Gems/1.8/gems/chef-server-0.5.3/bin/../lib/controllers/cookbook_files.rb:55:in `show'
/Library/Ruby/Gems/1.8/gems/chef-server-0.5.3/bin/../lib/controllers/cookbook_files.rb:37:in `index'

Activity

Hide
AJ Christensen added a comment - 10/Feb/09 4:05 AM

This one looks simple but complex?

Thoughts?

Show
AJ Christensen added a comment - 10/Feb/09 4:05 AM This one looks simple but complex? Thoughts?
Hide
Adam Jacob added a comment - 12/Feb/09 7:09 AM

The issue here is that the cookbook loader uses a shell glob to find the right files:

Dir['**/*'], for example.

Show
Adam Jacob added a comment - 12/Feb/09 7:09 AM The issue here is that the cookbook loader uses a shell glob to find the right files: Dir['**/*'], for example.
Hide
Adam Jacob added a comment - 12/Feb/09 4:29 PM

This bug is fixed, and pushed to opscode/master. We now find files that start with ., or even ..f, but not the directories . or ..!

Show
Adam Jacob added a comment - 12/Feb/09 4:29 PM This bug is fixed, and pushed to opscode/master. We now find files that start with ., or even ..f, but not the directories . or ..!
Hide
Dave Myron added a comment - 04/Apr/09 6:40 AM

Actually, it wasn't quite fixed. It didn't find dotfiles in directories. For example, if I were sending up a cookbook with files/root/.ssh/id_rsa, it would not be found.

I've fixed it though. Find it at http://github.com/contentfree/chef/commit/d2e456342a91818184b39a1541928633bea0c566

Instead of putting in several different globs to match the leading dot, I just used the File::FNM_DOTMATCH flag with a Dir.glob call. All specs (plus a new one for the above scenario) pass.

Show
Dave Myron added a comment - 04/Apr/09 6:40 AM Actually, it wasn't quite fixed. It didn't find dotfiles in directories. For example, if I were sending up a cookbook with files/root/.ssh/id_rsa, it would not be found. I've fixed it though. Find it at http://github.com/contentfree/chef/commit/d2e456342a91818184b39a1541928633bea0c566 Instead of putting in several different globs to match the leading dot, I just used the File::FNM_DOTMATCH flag with a Dir.glob call. All specs (plus a new one for the above scenario) pass.
Hide
Dave Myron added a comment - 30/Jun/09 2:31 AM

Problem still exists in 0.7.4. My fix above still applies and takes care of the issue.

Show
Dave Myron added a comment - 30/Jun/09 2:31 AM Problem still exists in 0.7.4. My fix above still applies and takes care of the issue.
Hide
AJ Christensen added a comment - 30/Jun/09 2:52 AM

Thanks, merged into opscode/master, will go into 0.7.6

Show
AJ Christensen added a comment - 30/Jun/09 2:52 AM Thanks, merged into opscode/master, will go into 0.7.6
Hide
AJ Christensen added a comment - 30/Jun/09 4:29 PM

Merged and pushed

Show
AJ Christensen added a comment - 30/Jun/09 4:29 PM Merged and pushed

People

Vote (0)
Watch (0)

Dates

  • Created:
    03/Feb/09 3:23 AM
    Updated:
    30/Jun/09 4:29 PM
    Resolved:
    30/Jun/09 2:52 AM