Bug #1544
File resource fails when recursing from a source directory that contains dangling symlinks
| Status: | Closed | Start date: | 09/02/2008 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 100% |
||
| Category: | file | |||
| Target version: | 0.24.6 | |||
| Affected Puppet version: | 0.24.4 | Branch: | ||
| Keywords: | file
directory recurse symlink |
|||
| Votes: | 0 |
Description
Using a file resource with “ensure => directory, recurse => true” fails when the source directory contains dangling symlinks. The directory is created, but none of the content is copied from the source.
h2. Manifest file_directory_recurse_symlink.pp
This manifest reproduces the issue. The manifest creates a source directory, containing a file with content, and a dangling symlink. It also creates another directory with the first directory as source, and with “recurse => true”.
The destination directory is created, but neither the file, nor the dangling symlink is copied from the source directory. Instead, an error message is displayed:
err: //File[/tmp/ssm_test_copy]: Failed to generate additional resources during transaction: undefined method `each' for nil:NilClass
This was seen when using “puppetd” and “puppetmasterd”, the manifest reproduces the same issue when running with “puppet”.
h2. Manifest file_directory_recurse_unreadable_file.pp
This manifests shows “good” behaviour when encountering unreadable files.
I would normally expect a dangling symlink in a recursed directory to be created in the same way on the puppet node, pointing to the same place.
History
Updated by James Turnbull over 3 years ago
- Status changed from Unreviewed to Accepted
- Target version set to 0.24.6
Updated by Paul Nasrat over 3 years ago
- Assignee set to Paul Nasrat
Thanks I’ve converted this into a failing rspec test
http://github.com/pnasrat/puppet/commit/e6090a4f07059f278596682a381541c9f7a0f940
I’m looking into.
Updated by Paul Nasrat over 3 years ago
I’ve updated my tickets/0.24.x/1544 branch with a test for the working behaviour.
Trying to get patched…
git pull git://github.com/pnasrat/puppet.git tickets/0.24.x/1544
Updated by Paul Nasrat over 3 years ago
Failing path is in Mount.reclist when it calls this for the dangling symlink:
reclist(basepath, File.join(abspath, child), recurse, ignore).each { |cobj|
ary << cobj
}
Updated by Paul Nasrat over 3 years ago
# Recursively list the files in this tree.
def reclist(basepath, abspath, recurse, ignore)
abspath = basepath if abspath.nil?
relpath = abspath.sub(%r{^#{basepath}}, '')
relpath = "/#{relpath}" if relpath[0] != ?/ #/
return unless FileTest.exists?(abspath)
...
This breaks as for dangling symlinks FileTest.exists? is false so we get a nil in the middle of the recursive call.
Updated by Paul Nasrat over 3 years ago
- Status changed from Accepted to Closed
- % Done changed from 0 to 100
Applied in changeset commit:a30ecf2aeffd71960bd806fb28cd6d1b8adc2452.