Weird empty attributes


#1

hi,

i’m investigating an weird problem. our recipe works well, most of time.

say, you have a base recipe with some basic attributes. other recipe
include_attribute the recipe and create new default attributes.

in common/attributes/default.rb

case node[:platform]
when "freebsd"
default.common[:etc_dir] = "/usr/local/etc"
else
default.common[:etc_dir] = "/etc"
end

in other_recipe/attributes/default.rb

include_attributes “common”

default.other_recipe[:config_dir] = “#{node[:common][:etc_dir]}/myconfig_dir”

this works as expected, most of time. the problem is, it fails
sometimes on different nodes. when it failed, failed-run-data.json
contains something like:


“default”: {
“other_recipe”: {
“config_fir”: “/myconfig_dir”,

}
}

this means node[:common][:etc_dir] is empty. interestingly,
node[:common][:etc_dir] is defined properly in failed-run-data.json;
it is “/usr/local/etc”.

when it failed, I usually ssh to the node, run chef-client manually
and it succeeds.

this is very hard to reproduce as it happens randomly on some
nodes. at least, when you restart chef-client daemon, everything
is okay for a while. if you don’t restart it, chef-run keeps
failing.

does anyone know where to look at?


Tomoyuki Sakurai


#2

which version of json gem you have installed on the nodes where chef-client
fails ?

–max

On Fri, Feb 10, 2012 at 12:55 AM, Tomoyuki Sakurai <
tomoyukis@reallyenglish.com> wrote:

hi,

i’m investigating an weird problem. our recipe works well, most of time.

say, you have a base recipe with some basic attributes. other recipe
include_attribute the recipe and create new default attributes.

in common/attributes/default.rb

case node[:platform]
when "freebsd"
default.common[:etc_dir] = "/usr/local/etc"
else
default.common[:etc_dir] = "/etc"
end

in other_recipe/attributes/default.rb

include_attributes “common”

default.other_recipe[:config_dir] =
"#{node[:common][:etc_dir]}/myconfig_dir"

this works as expected, most of time. the problem is, it fails
sometimes on different nodes. when it failed, failed-run-data.json
contains something like:


“default”: {
“other_recipe”: {
“config_fir”: “/myconfig_dir”,

}
}

this means node[:common][:etc_dir] is empty. interestingly,
node[:common][:etc_dir] is defined properly in failed-run-data.json;
it is “/usr/local/etc”.

when it failed, I usually ssh to the node, run chef-client manually
and it succeeds.

this is very hard to reproduce as it happens randomly on some
nodes. at least, when you restart chef-client daemon, everything
is okay for a while. if you don’t restart it, chef-run keeps
failing.

does anyone know where to look at?


Tomoyuki Sakurai


#3

On Sat, Feb 11, 2012 at 3:22 AM, Max Gorbul max@gorbul.net wrote:

which version of json gem you have installed on the nodes where chef-client
fails ?

json-1.5.1 on all FreeBSD nodes. does it have any known problem?


Tomoyuki Sakurai


#4

I have upgraded yesterday to 1.6.1 from 1.4.6 because I used to have 500
internal server error from chef-server randomly because of broken JSON
(node attributes) has been sent ot the server when node.save was called. I
just thought that it might be your issues as well.

–max

On Fri, Feb 10, 2012 at 6:08 PM, Tomoyuki Sakurai <
tomoyukis@reallyenglish.com> wrote:

On Sat, Feb 11, 2012 at 3:22 AM, Max Gorbul max@gorbul.net wrote:

which version of json gem you have installed on the nodes where
chef-client
fails ?

json-1.5.1 on all FreeBSD nodes. does it have any known problem?


Tomoyuki Sakurai


#5

On Sat, Feb 11, 2012 at 12:13 PM, Max Gorbul max@gorbul.net wrote:

I have upgraded yesterday to 1.6.1 from 1.4.6 because I used to have 500
internal server error from chef-server randomly because of broken JSON (node
attributes) has been sent ot the server when node.save was called. I just
thought that it might be your issues as well.

thanks. I’ve upgraded json to 1.6.1 this morning.
as the problem doesn’t happen immediately, i’ll report again
when it happens.


Tomoyuki Sakurai