[PUP-6033] Recursive file resource in static catalog creates empty directory when source has trailing "/" Created: 2016/03/09  Updated: 2017/03/31  Resolved: 2016/03/10

Status: Closed
Project: Puppet
Component/s: None
Affects Version/s: None
Fix Version/s: PUP 4.4.0

Type: Bug Priority: Normal
Reporter: Josh Cooper Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: burnside-ss
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Blocks
Relates
relates to PUP-7402 handle trailing slashes in references... Closed
Template:
Epic Link: (Burnside) Direct Puppet: Client Static Catalog
Story Points: 1
Sprint: Client 2016-03-23
Release Notes: Not Needed
Release Notes Summary: Ensuring unreleased static catalogs behave the same as non-static catalogs when sources have trailing slashes.

 Description   

The agent strips trailing slashes when normalizing the source parameter, which causes it to not find the metadata in the catalog.



 Comments   
Comment by Josh Cooper [ 2016/03/10 ]

To verify, create a manifest with a file resource whose source parameter has a trailing slash, and contains subdirectories and files:

class example_mod {
  file { '/tmp/empty':
    ensure => directory,
    recurse => true,
    source => 'puppet:///modules/example_mod/example_dir/',
  }
}

Verify puppet copies the tree as opposed to creating an empty directory.

Comment by William Hopper [ 2016/03/10 ]

FR: Verified on puppet#stable:

On the master, we have:

[root@nweot3buh2vwtko tmp]# ls -l /etc/puppetlabs/code/environments/production/modules/example_mod/files/example_dir/
total 4
drwxr-xr-x. 2 root root 27 Mar 10 16:04 sub_dir
-rw-r--r--. 1 root root  3 Mar 10 16:04 top_level_file
 
[root@nweot3buh2vwtko tmp]# ls -l /etc/puppetlabs/code/environments/production/modules/example_mod/files/example_dir/sub_dir/
total 4
-rw-r--r--. 1 root root 9 Mar 10 16:04 sub_level_file

With a manifest,

node default {
  file { '/tmp/empty':
    ensure => directory,
    recurse => true,
    source => 'puppet:///modules/example_mod/example_dir/',
  }
}

Upon an agent run, the static catalog is generated on the master:

2016-03-10 16:37:45,413 INFO  [qtp1327998499-23] [puppet-server] Puppet Inlined resource metadata into static catalog for d34erj8fpc0nil8.delivery.puppetlabs.net in environment production in 0.01 seconds
2016-03-10 16:37:45,414 INFO  [qtp1327998499-23] [puppet-server] Puppet Compiled static catalog for d34erj8fpc0nil8.delivery.puppetlabs.net in environment production in 0.04 seconds

... and on the agent, a non-empty directory is produced, and contains all of the subdirectories and files from the master moduledir.

[root@d34erj8fpc0nil8 ~]# ls /tmp/empty/
sub_dir  top_level_file
 
[root@d34erj8fpc0nil8 ~]# ls /tmp/empty/sub_dir/
sub_level_file

Also verified that the same happens when the trailing slash is removed in the manifest:

[root@d34erj8fpc0nil8 ~]# ls -l /tmp/empty/
total 4
drwxr-xr-x. 2 root root 27 Mar 10 16:43 sub_dir
-rw-r--r--. 1 root root 13 Mar 10 16:43 top_level_file
 
[root@d34erj8fpc0nil8 ~]# ls -l /tmp/empty/sub_dir/
total 4
-rw-r--r--. 1 root root 13 Mar 10 16:43 sub_level_file

Generated at Sat Feb 22 06:07:26 PST 2020 using JIRA 7.7.1#77002-sha1:e75ca93d5574d9409c0630b81c894d9065296414.