Notifies on resource not notifying

On Wednesday, January 2, 2013 at 10:02 AM, Seif Attar wrote:

On 2 January 2013 16:43, Daniel DeLeo <dan@kallistec.com (mailto:dan@kallistec.com)> wrote:

For sanity's sake can you copy the debug code you have in the ruby block to outside of the ruby block (so it runs during compile time)?
Sure, updated gist:

template resource not notifying · GitHub

So you don't think it has anything to do with https://github.com/opscode/chef/blob/master/lib/chef/provider/file.rb#L148-L153 as the comment says that reporting won't work.
That's correct, the reporting stuff has to do with explicitly recording before and after state for resources for the purpose of storing that information elsewhere.

I'll need to look at it more in-depth, but at the moment I'm seeing something odd with the names of the resources and the path separators:

localhost [2013-01-02T17:48:42+00:00] INFO: Processing template[C:\Temp\bt97\1.8.9-alpha-01133\Deployment\Settings\CHEF.js] action nothing (Wiggle_Billing::default line /chef/cache/cookbooks/Wiggle_Billing/recipes/default.rb)
localhost [2013-01-02T17:49:36+00:00] INFO: windows_zipfile[unzip_artefacts] sending create action to template[C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js] (immediate)

localhost [2013-01-02T17:49:36+00:00] INFO: Processing template[C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js] action create (Wiggle_Billing::default line /chef/cache/cookbooks/Wiggle_Billing/recipes/default.rb)

localhost [2013-01-02T17:49:37+00:00] INFO: template[C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js] backed up to c:/chef/backup/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js.chef-20130102174937

localhost [2013-01-02T17:49:37+00:00] INFO: template[C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js] updated content

Note the forward slash vs. backward slash. It may be a red herring, I'll have to do more investigation.

--
Daniel DeLeo

Thanks for looking into this, let me know if I can help with anything.

I tried to work around the problem by putting all the resources in an if
statement instead of having and not_if and notifies (is this even allowed?)

I am getting an error in the template now that I need to set username or
group, updated recipe and log:

Is there a better way to work around the problem, so that no changes occur
if the file exists?

Thanks again,
Seif

On Wednesday, January 2, 2013 at 1:40 PM, Seif Attar wrote:

Thanks for looking into this, let me know if I can help with anything.

I tried to work around the problem by putting all the resources in an if statement instead of having and not_if and notifies (is this even allowed?)

I am getting an error in the template now that I need to set username or group, updated recipe and log:

template resource not notifying · GitHub
Is this with a pristine copy of Chef? I'm curious as to how you're ending up with owner, group, and mode set on that resource. The code you were looking at before would do that (File#load_current_resource_attrs), but it should be skipped on windows.

Is there a better way to work around the problem, so that no changes occur if the file exists?

Thanks again,
Seif

--
Daniel DeLeo

On 2 January 2013 22:20, Daniel DeLeo dan@kallistec.com wrote:

Is this with a pristine copy of Chef? I'm curious as to how you're ending
up with owner, group, and mode set on that resource. The code you were
looking at before would do that (File#load_current_resource_attrs), but it
should be skipped on windows.

I installed chef on the vm using the msi installer and haven't modified the
code in anyway if that is what you mean by pristine.

It is all mind boggling to me, because it install and executes fine when I
remove the if statement that checks if the file exists in the workaround,
which is why I assumed what I am doing with the if statement is wrong :S

I have added the stack trace to

Maybe it helps unravel the mystery

On Wednesday, January 2, 2013 at 3:24 PM, Seif Attar wrote:

On 2 January 2013 22:20, Daniel DeLeo <dan@kallistec.com (mailto:dan@kallistec.com)> wrote:

Is this with a pristine copy of Chef? I'm curious as to how you're ending up with owner, group, and mode set on that resource. The code you were looking at before would do that (File#load_current_resource_attrs), but it should be skipped on windows.
I installed chef on the vm using the msi installer and haven't modified the code in anyway if that is what you mean by pristine.
Then can you try commenting out that method? That's the only place I can think of where you'd be getting unix-style permissions attributes getting set on your resource.

It is all mind boggling to me, because it install and executes fine when I remove the if statement that checks if the file exists in the workaround, which is why I assumed what I am doing with the if statement is wrong :S

I have added the stack trace to
template resource not notifying · GitHub

Maybe it helps unravel the mystery

--
Daniel DeLeo

On 3 January 2013 18:25, Daniel DeLeo dan@kallistec.com wrote:

Then can you try commenting out that method? That's the only place I can
think of where you'd be getting unix-style permissions attributes getting
set on your resource.

I commented out all lines inside File#load_current_resource_attrs and added

    Chef::Log.info("current_resource '#{@current_resource.inspect}'")
    Chef::Log.info("new_resource '#{@new_resource.inspect}'")

Resulting in (sorry about the messy layout):

localhost [2013-01-03T19:20:25+00:00] INFO: current_resource
'<template[C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js]
@name: "C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js" @noop:
nil @before: nil @params: {} @provider: Chef::Provider::Template
@allowed_actions: [:nothing, :create, :delete, :touch, :create_if_missing]
@action: "create" @updated: false @updated_by_last_action: false @supports:
{} @ignore_failure: false @retries: 0 @retry_delay: 2 @source_line: nil
@elapsed_time: 0 @resource_name: :template @path:
"C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js" @backup: 5
@diff: nil @source: "CHEF.js.erb" @cookbook: nil @local: false @variables:
{} @checksum:
"fe6bed989662a2d206442d5fa143ce9976ccafd802947c68e5f1f2ee6d19d6eb">'
localhost [2013-01-03T19:20:25+00:00] INFO: new_resource
'<template[C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js]
@name: "C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js" @noop:
nil @before: nil @params: {} @provider: Chef::Provider::Template
@allowed_actions: [:nothing, :create, :delete, :touch, :create_if_missing]
@action: [:create] @updated: true @updated_by_last_action: false @supports:
{} @ignore_failure: false @retries: 0 @retry_delay: 2 @source_line:
"c:/chef/cache/cookbooks/Wiggle_Billing/recipes/default.rb:32:in
`from_file'" @elapsed_time: 0 @resource_name: :template @path:
"C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js" @backup: 5
@diff: "--- " @source: "CHEF.js.erb" @cookbook: nil @local: false
@variables: {} @cookbook_name: "Wiggle_Billing" @recipe_name: "default"
@checksum:
"fe6bed989662a2d206442d5fa143ce9976ccafd802947c68e5f1f2ee6d19d6eb" @owner:
0 @group: 0 @mode: 420 @rights: nil @deny_rights: nil @inherits: nil>'

And then I get the same exception Must specify username, group or SID: 0

On Thursday, January 3, 2013 at 11:39 AM, Seif Attar wrote:

On 3 January 2013 18:25, Daniel DeLeo <dan@kallistec.com (mailto:dan@kallistec.com)> wrote:

Then can you try commenting out that method? That's the only place I can think of where you'd be getting unix-style permissions attributes getting set on your resource.
I commented out all lines inside File#load_current_resource_attrs and added

    Chef::Log.info (http://Log.info)("current_resource '#{@current_resource.inspect}'")
    Chef::Log.info (http://Log.info)("new_resource '#{@new_resource.inspect}'")

Resulting in (sorry about the messy layout):

localhost [2013-01-03T19:20:25+00:00] INFO: current_resource '<template[C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js] @name: "C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js" @noop: nil @before: nil @params: {} @provider: Chef::Provider::Template @allowed_actions: [:nothing, :create, :delete, :touch, :create_if_missing] @action: "create" @updated: false @updated_by_last_action: false @supports: {} @ignore_failure: false @retries: 0 @retry_delay: 2 @source_line: nil @elapsed_time: 0 @resource_name: :template @path: "C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js" @backup: 5 @diff: nil @source: "CHEF.js.erb" @cookbook: nil @local: false @variables: {} @checksum: "fe6bed989662a2d206442d5fa143ce9976ccafd802947c68e5f1f2ee6d19d6eb">'
localhost [2013-01-03T19:20:25+00:00] INFO: new_resource '<template[C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js] @name: "C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js" @noop: nil @before: nil @params: {} @provider: Chef::Provider::Template @allowed_actions: [:nothing, :create, :delete, :touch, :create_if_missing] @action: [:create] @updated: true @updated_by_last_action: false @supports: {} @ignore_failure: false @retries: 0 @retry_delay: 2 @source_line: "c:/chef/cache/cookbooks/Wiggle_Billing/recipes/default.rb:32:in `from_file'" @elapsed_time: 0 @resource_name: :template @path: "C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js" @backup: 5 @diff: "--- " @source: "CHEF.js.erb" @cookbook: nil @local: false @variables: {} @cookbook_name: "Wiggle_Billing" @recipe_name: "default" @checksum: "fe6bed989662a2d206442d5fa143ce9976ccafd802947c68e5f1f2ee6d19d6eb" @owner: 0 @group: 0 @mode: 420 @rights: nil @deny_rights: nil @inherits: nil>'

And then I get the same exception Must specify username, group or SID: 0

Okay, then we need to track down where these values are being set. Try this:

class Chef
class Resource
class Template
def mode(*args)
unless args.empty?
Chef::Log.warn("Template mode being set to '#{args.inspect}' from:")
Chef::Log.warn(caller.join("\n"))
end
super
end
end
end
end

--
Daniel DeLeo

On 3 January 2013 23:57, Daniel DeLeo dan@kallistec.com wrote:

Okay, then we need to track down where these values are being set. Try
this:

class Chef
class Resource
class Template
def mode(*args)
unless args.empty?
Chef::Log.warn("Template mode being set to '#{args.inspect}'
from:")
Chef::Log.warn(caller.join("\n"))
end
super
end
end
end
end

Wasn't sure where to add this, but managed to crowbar it into the template
mixin. output:

I modified the template.rb and added

          if Chef::Platform.windows?
            return
          end

on line 66 after access_control.set_all!

And I am no longer getting that exception now.