Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making sure file exist before attemping unlinking it. Otherwise cause er... #1393

Closed
wants to merge 1 commit into from

Conversation

sysbot
Copy link

@sysbot sysbot commented Apr 27, 2014

When "force_unlink true" is use, if the file doesn't already exist, file creation will fail because the old code will attempt to unlink it without checking to see if it exist.

  • file[/etc/resolvconf/resolv.conf.d/tail] action create [2014-04-27T18:53:31+00:00] INFO: Processing file[/etc/resolvconf/resolv.conf.d/tail] action create (resolvconf::install line 23)

    ================================================================================

    Error executing action create on resource 'file[/etc/resolvconf/resolv.conf.d/tail]'

    Errno::ENOENT

    No such file or directory - /etc/resolvconf/resolv.conf.d/tail

    Resource Declaration:

    In /tmp/kitchen/cache/cookbooks/resolvconf/recipes/install.rb

    23: file "/etc/resolvconf/resolv.conf.d/tail" do
    24:   mode    00644
    25:   content "abc"
    26:   action :create
    27:   # Remove file if it is not a regular file (e.g. a symlink)
    
    28:   # This is useful, as sometimes the backup stored in the file "original"
    29:   # is symlinked to "tail"
    30:   force_unlink true
    31: end
    

    Compiled Resource:

    Declared in /tmp/kitchen/cache/cookbooks/resolvconf/recipes/install.rb:23:in `from_file'

    file("/etc/resolvconf/resolv.conf.d/tail") do
    provider Chef::Provider::File

     action [:create]
     retries 0
     retry_delay 2
     guard_interpreter :default
     path "/etc/resolvconf/resolv.conf.d/tail"
     backup 5
     atomic_update true
     force_unlink true
     cookbook_name "resolvconf"
     recipe_name "install"
     mode 420
     content "abc"
    

    end

… error below:

  * file[/etc/resolvconf/resolv.conf.d/tail] action create       [2014-04-27T18:53:31+00:00] INFO: Processing file[/etc/resolvconf/resolv.conf.d/tail] action create (resolvconf::install line 23)

       ================================================================================

       Error executing action `create` on resource 'file[/etc/resolvconf/resolv.conf.d/tail]'
       ================================================================================

       Errno::ENOENT
       -------------
       No such file or directory - /etc/resolvconf/resolv.conf.d/tail

       Resource Declaration:
       ---------------------
       # In /tmp/kitchen/cache/cookbooks/resolvconf/recipes/install.rb

        23: file "/etc/resolvconf/resolv.conf.d/tail" do
        24:   mode    00644
        25:   content "abc"
        26:   action :create
        27:   # Remove file if it is not a regular file (e.g. a symlink)

        28:   # This is useful, as sometimes the backup stored in the file "original"
        29:   # is symlinked to "tail"
        30:   force_unlink true
        31: end

       Compiled Resource:
       ------------------
       # Declared in /tmp/kitchen/cache/cookbooks/resolvconf/recipes/install.rb:23:in `from_file'

       file("/etc/resolvconf/resolv.conf.d/tail") do
         provider Chef::Provider::File

         action [:create]
         retries 0
         retry_delay 2
         guard_interpreter :default
         path "/etc/resolvconf/resolv.conf.d/tail"
         backup 5
         atomic_update true
         force_unlink true
         cookbook_name "resolvconf"
         recipe_name "install"
         mode 420
         content "abc"
       end
sysbot pushed a commit to sysbot/resolvconf that referenced this pull request Apr 27, 2014
… check for file exist before unlink. Pull request submited for this fix chef/chef#1393
@lamont-granquist
Copy link
Contributor

dup of #1383

dennybaa pushed a commit to dennybaa/resolvconf that referenced this pull request Oct 28, 2014
… check for file exist before unlink. Pull request submited for this fix chef/chef#1393
@chef chef locked and limited conversation to collaborators Nov 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants