HomePhorge

(#14599) Handle ENOTDIR in file type
b572810ed207Unpublished

Unpublished Commit ยท Learn More

Repository Importing: This repository is still importing.

Description

(#14599) Handle ENOTDIR in file type

If a file resource is used with a path where a component of path is not
a directory, the stat systemcall can raise the error Errno::ENOTDIR
which was not handled by the file type.

This can lead to the following error (if e.g /tmp/xx is a normal file)

err: /Stage[main]//File[/tmp/xx/yy/zz/1]: Could not evaluate: Not a
directory - /tmp/xx/yy/zz/1

Catch the error and return nil in the stat method like we do for absent
files or file where we do not have the permission to stat.

Puppet will still raise errors when trying to create such a file of
course like

err: /Stage[main]//File[/etc/fstab/foo]/ensure: change from absent to
file failed: Could not set 'file on ensure: Not a directory -
/etc/fstab/foo at line

But something like

puppet apply -ve 'file { "/etc/fstab/foo": ensure => absent}'

will now work without errors because /etc/fstab/foo is indeed absent.

Details

Provenance
Stefan Schulte <stefan.schulte@taunusstein.net>Authored on
vanmeeuwenPushed on Jun 2 2015, 2:22 PM
Parents
rPU638a6e433c22: Merge branch '2.7rc' into 2.7.x
Branches
Unknown
Tags
Unknown

Event Timeline

Stefan Schulte <stefan.schulte@taunusstein.net> committed rPUb572810ed207: (#14599) Handle ENOTDIR in file type (authored by Stefan Schulte <stefan.schulte@taunusstein.net>).May 21 2012, 12:25 AM