[chef] RE: Chef 11.6 Windows, error with templates?


Chronological Thread 
  • From: "McDonald, Andrew - EALA" < >
  • To: " " < >
  • Subject: [chef] RE: Chef 11.6 Windows, error with templates?
  • Date: Fri, 26 Jul 2013 10:58:53 -0700
  • Accept-language: en-US
  • Acceptlanguage: en-US

I had a similar problem with the sensu cookbook last night. Basically, its having problems with paths that start with /,

 

For me, it didn’t happen on the first run, but only on subsequent runs, basically because it seems to only happen if the target file already exists, but having looked into it, it could happen in a number of circumstances.

 

Problem seems to boil down to the fact that /something is being interpreted as an absolute path in some instances, where really its relative to the current drive, but the windows file api wrappers are prepending \\?\ to the path names to support long path names, unfortunately in order for that to work, the path name must be absolute.

 

To work around it in my case for now, I overrode the default sensu directory from /etc/sensu to c:\etc\sensu, which stops the error occurring.

 

Here’s an example in chef\win32\file.rb  ( method self.symlink? ) where its failing.

 

        path = encode_path(file_name)

        if ::File.exists?(file_name)

          if ((GetFileAttributesW(path) & FILE_ATTRIBUTE_REPARSE_POINT) > 0)

            file_search_handle(file_name) do |handle, find_data|

 

Basically, the file_name contains /etc/sensu, which encode_path turns into \\?\\etc\sensu, which isn’t a valid path, as it doesn’t include a drive specifier ( \\?\ format paths must be fully qualified ),

GetFileAttributesW then returns -1 because the file doesn’t exist, ( but the File.exists? call succeeds as it uses the un-encoded path name. ) the -1 passes the & FILE_ATTRIBUTE_REPARSE_POINT check as -1 has all bits set, and so it goes into the file_search_handle method, which in turn does its own encode on the file_name, and finally that’s where the actual file not found error is raised.

 

Unfortunately I’m a total ruby & chef noob, so for now I’m avoiding the issue for now by changing my path to include the drive specifier. I’m posting the details in the hope that someone more familiar with the code can suggest a proper solution.

 

Thanks

Andrew McDonald

 

From: Brian Anderson [mailto:
Sent: Friday, July 26, 2013 10:38 AM
To:
Subject: [chef] Chef 11.6 Windows, error with templates?

 

I tried booting up a new Windows Server instance today. Since the knife-windows plugin always installs the latest version of Chef, I got 11.6.

 

My chef run blew up pretty quickly at the first cookbook_file I hit:

 

 

ec2-184-72-136-111.compute-1.amazonaws.com ================================================================================

ec2-184-72-136-111.compute-1.amazonaws.com Error executing action `create` on resource 'cookbook_file[/Progra~1/NSClient++/nsclient.ini]'

ec2-184-72-136-111.compute-1.amazonaws.com ================================================================================

ec2-184-72-136-111.compute-1.amazonaws.com Chef::Exceptions::Win32APIError

ec2-184-72-136-111.compute-1.amazonaws.com -------------------------------

ec2-184-72-136-111.compute-1.amazonaws.com The system cannot find the path specified.

ec2-184-72-136-111.compute-1.amazonaws.com ---- Begin Win32 API output ----

ec2-184-72-136-111.compute-1.amazonaws.com System Error Message: The system cannot find the path specified.

ec2-184-72-136-111.compute-1.amazonaws.com ---- End Win32 API output ----

ec2-184-72-136-111.compute-1.amazonaws.com # In c:/chef/cache/cookbooks/nagios/recipes/client-win.rb

ec2-184-72-136-111.compute-1.amazonaws.com  16: cookbook_file "/Progra~1/NSClient++/nsclient.ini" do

ec2-184-72-136-111.compute-1.amazonaws.com  17:         source "nsclient.ini"

ec2-184-72-136-111.compute-1.amazonaws.com # Declared in c:/chef/cache/cookbooks/nagios/recipes/client-win.rb:16:in `from_file'

ec2-184-72-136-111.compute-1.amazonaws.com cookbook_file("/Progra~1/NSClient++/nsclient.ini") do

ec2-184-72-136-111.compute-1.amazonaws.com   provider Chef::Provider::CookbookFile

ec2-184-72-136-111.compute-1.amazonaws.com   path "/Progra~1/NSClient++/nsclient.ini"

ec2-184-72-136-111.compute-1.amazonaws.com   recipe_name "client-win"

 

 

I disabled that recipe and got a similar error the first time it hit a template.

 

I read the release notes about the file changes, but I didn't think I was doing anything that should cause trouble. Is there anything in that compiled resource that looks wrong?

 

I rolled back to 11.4.4 on the instance and everything ran as expected.

 

 

 

 

 

Brian

--
Brian Anderson | Operations Engineer
Phone 781.696.1304 

www.affectiva.com

     




Archive powered by MHonArc 2.6.16.

§