Jira (PUP-4442) The error message associated with a file resource that requires a non-existent directory is misleading.

22 views
Skip to first unread message

Rob Nelson (JIRA)

unread,
Apr 20, 2015, 6:20:56 PM4/20/15
to puppe...@googlegroups.com
Rob Nelson created an issue
 
Puppet / Bug PUP-4442
The error message associated with a file resource that requires a non-existent directory is misleading.
Issue Type: Bug Bug
Affects Versions: PUP 3.7.4
Assignee: Unassigned
Components: Puppet Server
Created: 2015/04/20 3:20 PM
Priority: Normal Normal
Reporter: Rob Nelson

When managing a file, if you specify a location that requires an intermediate directory that is missing, and not managed by puppet, the error message is misleading. It implies that the issue is with the temp file created, rather than the missing directory itself. For example, when managing /etc/eyaml/config.yaml, /etc/eyaml does not exist:

Catalog:
file

{'/etc/eyaml/config.yaml': ensure => file, content => template('eyaml/config.yaml.erb'), }

Error:
Error: Could not set 'file' on ensure: No such file or directory - /etc/eyaml/config.yaml20150420-14321-me6waj.lock at 66:/etc/puppetlabs/puppet/environments/eyaml/dist/eyaml/manifests/init.pp
Error: Could not set 'file' on ensure: No such file or directory - /etc/eyaml/config.yaml20150420-14321-me6waj.lock at 66:/etc/puppetlabs/puppet/environments/eyaml/dist/eyaml/manifests/init.pp
Wrapped exception:
No such file or directory - /etc/eyaml/config.yaml20150420-14321-me6waj.lock
Error: /Stage[main]/Eyaml/File[/etc/eyaml/config.yaml]/ensure: change from absent to file failed: Could not set 'file' on ensure: No such file or directory - /etc/eyaml/config.yaml20150420-14321-me6waj.lock at 66:/etc/puppetlabs/puppet/environments/eyaml/dist/eyaml/manifests/init.pp

The preference would be to generate an error that indicates that /etc/eyaml does not exist, or even a generic "Parent directories for $file do not exist"

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.3.15#6346-sha1:dbc023d)
Atlassian logo

Russell Miller (JIRA)

unread,
Apr 20, 2015, 6:26:47 PM4/20/15
to puppe...@googlegroups.com
Russell Miller commented on Bug PUP-4442
 
Re: The error message associated with a file resource that requires a non-existent directory is misleading.

I have an ongoing support case that Tim Purkerson is working on with me, which has an identical root cause, so I'm going to pile on.

The problem is the code flow in uniquefile.rb.

It attempts to create the file using Dir.mkdir, but there is no error checking on that call. It fails, but there is an "ensure" on the calling block, which will attempt to remove it whether or not it was created. So it's the removal that fails, even though the file was never created for other reasons.

The Dir.mkdir needs to be somehow checked, and the ensure needs to not run if the mkdir fails.

Henrik Lindberg (JIRA)

unread,
Apr 20, 2015, 6:26:48 PM4/20/15
to puppe...@googlegroups.com
Henrik Lindberg updated an issue
 
Change By: Henrik Lindberg
When managing a file, if you specify a location that requires an intermediate directory that is missing, and not managed by puppet, the error message is misleading. It implies that the issue is with the temp file created, rather than the missing directory itself. For example, when managing /etc/eyaml/config.yaml, /etc/eyaml does not exist:

Catalog:
{code}
  file {'/etc/eyaml/config.yaml':
    ensure => file,
    content => template('eyaml/config.yaml.erb'),
  }
{code}
{code}
Error:
Error: Could not set 'file' on ensure: No such file or directory - /etc/eyaml/config.yaml20150420-14321-me6waj.lock at 66:/etc/puppetlabs/puppet/environments/eyaml/dist/eyaml/manifests/init.pp
Error: Could not set 'file' on ensure: No such file or directory - /etc/eyaml/config.yaml20150420-14321-me6waj.lock at 66:/etc/puppetlabs/puppet/environments/eyaml/dist/eyaml/manifests/init.pp
Wrapped exception:
No such file or directory - /etc/eyaml/config.yaml20150420-14321-me6waj.lock
Error: /Stage[main]/Eyaml/File[/etc/eyaml/config.yaml]/ensure: change from absent to file failed: Could not set 'file' on ensure: No such file or directory - /etc/eyaml/config.yaml20150420-14321-me6waj.lock at 66:/etc/puppetlabs/puppet/environments/eyaml/dist/eyaml/manifests/init.pp
{code}

The preference would be to generate an error that indicates that /etc/eyaml does not exist, or even a generic "Parent directories for $file do not exist"

Henrik Lindberg (JIRA)

unread,
Apr 20, 2015, 6:27:46 PM4/20/15
to puppe...@googlegroups.com
Henrik Lindberg updated an issue
Change By: Henrik Lindberg
Component/s: Puppet Server
Component/s: Types and Providers
Scrum Team: Client Platform

Josh Cooper (JIRA)

unread,
Sep 10, 2015, 2:19:02 AM9/10/15
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Fix Version/s: PUP 4.3.0
This message was sent by Atlassian JIRA (v6.4.11#64026-sha1:78f6ec4)
Atlassian logo

Josh Cooper (JIRA)

unread,
Sep 23, 2015, 5:20:16 PM9/23/15
to puppe...@googlegroups.com

Josh Cooper (JIRA)

unread,
Apr 6, 2017, 3:20:02 PM4/6/17
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Fix Version/s: PUP 4.y
Fix Version/s: PUP 5.y
This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe)
Atlassian logo

Moses Mendoza (JIRA)

unread,
May 17, 2017, 2:08:03 PM5/17/17
to puppe...@googlegroups.com

Moses Mendoza (JIRA)

unread,
May 17, 2017, 2:08:03 PM5/17/17
to puppe...@googlegroups.com

Moses Mendoza (JIRA)

unread,
May 18, 2017, 1:55:08 PM5/18/17
to puppe...@googlegroups.com

Josh Cooper (JIRA)

unread,
Nov 29, 2017, 12:41:02 AM11/29/17
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-4442
 
Re: The error message associated with a file resource that requires a non-existent directory is misleading.

The ensure behavior was fixed in https://github.com/puppetlabs/puppet/commit/ca60ff8e4c00139522cdb570f8d4c3bb3e2aa847 (in 4.4.2). However, puppet needs to rescue ENOENT if mkdir fails, and generate a meaningful error message, and the message should reference the parent directory, not the lock file. The current behavior is still confusing:

$ bundle exec puppet apply -e 'file { "/tmp/foo/bar/baz": ensure => file, content => "hi" }'
Notice: Compiled catalog for XXX in environment production in 0.02 seconds
Error: Could not set 'file' on ensure: No such file or directory @ dir_s_mkdir - /tmp/foo/bar/baz20171128-80116-1rs9wks.lock at line 1
Error: Could not set 'file' on ensure: No such file or directory @ dir_s_mkdir - /tmp/foo/bar/baz20171128-80116-1rs9wks.lock at line 1
Wrapped exception:
No such file or directory @ dir_s_mkdir - /tmp/foo/bar/baz20171128-80116-1rs9wks.lock
Error: /Stage[main]/Main/File[/tmp/foo/bar/baz]/ensure: change from 'absent' to 'file' failed: Could not set 'file' on ensure: No such file or directory @ dir_s_mkdir - /tmp/foo/bar/baz20171128-80116-1rs9wks.lock at line 1
Notice: Applied catalog in 0.01 seconds

This message was sent by Atlassian JIRA (v7.0.2#70111-sha1:88534db)
Atlassian logo

Josh Cooper (JIRA)

unread,
Nov 29, 2017, 12:41:02 AM11/29/17
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
May 7, 2020, 11:52:04 AM5/7/20
to puppe...@googlegroups.com
Josh Cooper assigned an issue to Josh Cooper
Change By: Josh Cooper
Assignee: Josh Cooper
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Melissa Stone (Jira)

unread,
May 7, 2020, 7:56:02 PM5/7/20
to puppe...@googlegroups.com

Melissa Stone (Jira)

unread,
May 7, 2020, 7:56:02 PM5/7/20
to puppe...@googlegroups.com
Melissa Stone updated an issue
 
Change By: Melissa Stone
Fix Version/s: PUP 5.y
Fix Version/s: PUP 6.16.0
Fix Version/s: PUP 5.5.20

Melissa Stone (Jira)

unread,
May 7, 2020, 8:00:03 PM5/7/20
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
May 11, 2020, 6:31:03 PM5/11/20
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Release Notes: Enhancement
Release Notes Summary: Improve the error message that occurs when trying to manage a file resource whose parent directory doesn't exist.

Josh Cooper (Jira)

unread,
May 11, 2020, 6:44:03 PM5/11/20
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-4442
 
Re: The error message associated with a file resource that requires a non-existent directory is misleading.

$  bx puppet apply -e "file { '/tmp/does/not/exist': ensure => file, content => 'abc' }"
Notice: Compiled catalog for localhost in environment production in 0.01 seconds
...
Error: /Stage[main]/Main/File[/tmp/does/not/exist]/ensure: change from 'absent' to 'file' failed: Could not set 'file' on ensure: No such file or directory - A directory component in /tmp/does/not/exist20200511-37000-vxasli.lock does not exist or is a dangling symbolic link (line: 1)

Melissa Stone (Jira)

unread,
May 13, 2020, 6:54:02 PM5/13/20
to puppe...@googlegroups.com

Claire Cadman (Jira)

unread,
May 19, 2020, 10:03:04 AM5/19/20
to puppe...@googlegroups.com

Ciprian Badescu (Jira)

unread,
Jul 2, 2020, 6:51:03 AM7/2/20
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages