Chef

DeepMerge fails to merge production data

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Fixed
  • Affects Version/s: 0.8.16
  • Fix Version/s: 0.9.0
  • Component/s: Chef Client
  • Labels:
    None
  • Environment:

    ruby-1.8.7-p249 on macosX (also exists on Ubuntu)

  • Triage Status:
    Triaged

Description

Some of my recipes fails to run properly on our 0.8 test cluster. I've isolated an issue in DeepMerge with our data and managed to extract a test case:

21/05 16:50 ~/test_case% ruby bug.rb
/Users/oct/.rvm/gems/ruby-1.8.7-p249@chef0.8/gems/chef-0.8.16/lib/chef/node/attribute.rb:338:in `auto_vivifiy': You tried to set a nested key, where the parent is not a hash-like object: fotonauts/balancers/search_server_host/search_server_host (ArgumentError)
from /Users/oct/.rvm/gems/ruby-1.8.7-p249@chef0.8/gems/chef-0.8.16/lib/chef/node/attribute.rb:243:in `get_value'
from /Users/oct/.rvm/gems/ruby-1.8.7-p249@chef0.8/gems/chef-0.8.16/lib/chef/node/attribute.rb:232:in `upto'
from /Users/oct/.rvm/gems/ruby-1.8.7-p249@chef0.8/gems/chef-0.8.16/lib/chef/node/attribute.rb:232:in `get_value'
from /Users/oct/.rvm/gems/ruby-1.8.7-p249@chef0.8/gems/chef-0.8.16/lib/chef/node/attribute.rb:94:in `each'
from /Users/oct/.rvm/gems/ruby-1.8.7-p249@chef0.8/gems/chef-0.8.16/lib/chef/node/attribute.rb:91:in `each'
from /Users/oct/.rvm/gems/ruby-1.8.7-p249@chef0.8/gems/chef-0.8.16/lib/chef/mixin/deep_merge.rb:114:in `deep_merge!'
from /Users/oct/.rvm/gems/ruby-1.8.7-p249@chef0.8/gems/chef-0.8.16/lib/chef/mixin/deep_merge.rb:128:in `deep_merge!'
from /Users/oct/.rvm/gems/ruby-1.8.7-p249@chef0.8/gems/chef-0.8.16/lib/chef/mixin/deep_merge.rb:114:in `each'
from /Users/oct/.rvm/gems/ruby-1.8.7-p249@chef0.8/gems/chef-0.8.16/lib/chef/mixin/deep_merge.rb:114:in `deep_merge!'
from /Users/oct/.rvm/gems/ruby-1.8.7-p249@chef0.8/gems/chef-0.8.16/lib/chef/mixin/deep_merge.rb:32:in `merge'
from bug.rb:8

Please see attached bug.rb and a.yml

Activity

Hide
Pierre Baillet added a comment - 21/May/10 2:56 PM

(no attachement in Jira ?!)

bug.rb:

require 'rubygems'
require 'yaml'
require 'chef'
require 'chef/mixin/deep_merge'

a_value = YAML.load(File.open('a.yml'))

value = Chef::Mixin::DeepMerge.merge(nil, a_value)

a.yml:

— &id007 !map:Mash
merge!: &id006 !ruby/object:Chef::Node::Attribute
attribute: !map:Mash
fotonauts: !map:Mash
balancers: &id001 !map:Mash
search_server_host: search.

auto_vivifiy_on_read: false
current_attribute: *id001
current_default: !map:Mash {}

current_override: &id005 !map:Mash {}

default: !map:Mash
fotonauts: !map:Mash
balancers: !map:Mash {}

has_been_read: false
override: !map:Mash {}

set_unless_value_present: false
state:

  • fotonauts
  • :balancers
  • search_server_host
    internal: false
Show
Pierre Baillet added a comment - 21/May/10 2:56 PM (no attachement in Jira ?!) bug.rb: require 'rubygems' require 'yaml' require 'chef' require 'chef/mixin/deep_merge' a_value = YAML.load(File.open('a.yml')) value = Chef::Mixin::DeepMerge.merge(nil, a_value) a.yml: — &id007 !map:Mash merge!: &id006 !ruby/object:Chef::Node::Attribute attribute: !map:Mash fotonauts: !map:Mash balancers: &id001 !map:Mash search_server_host: search. auto_vivifiy_on_read: false current_attribute: *id001 current_default: !map:Mash {} current_override: &id005 !map:Mash {} default: !map:Mash fotonauts: !map:Mash balancers: !map:Mash {} has_been_read: false override: !map:Mash {} set_unless_value_present: false state:
  • fotonauts
  • :balancers
  • search_server_host internal: false
Hide
Adam Jacob added a comment - 26/May/10 4:09 PM

We'll take a look at this.

Show
Adam Jacob added a comment - 26/May/10 4:09 PM We'll take a look at this.
Hide
Daniel DeLeo added a comment - 15/Jun/10 6:24 AM

Hi Pierre,
I cannot reproduce this now, I think it may have been incidentally fixed by another patch, possibly CHEF-1246.

Loading your data I get:

attrs = YAML.load_file('test.yml')
 => {"merge!"=>#<Chef::Node::Attribute:0x00000102844fb0 @attribute={"fotonauts"=>{"balancers"=>{"search_server_host"=>"search."}}},
@auto_vivifiy_on_read=false, @current_attribute={"search_server_host"=>"search."}, @current_default={}, @current_override={}, 
@default={"fotonauts"=>{"balancers"=>{}}}, @has_been_read=false, @override={}, @set_unless_value_present=false, @state=["fotonauts", :balancers, 
"search_server_host"]>, "internal"=>false}

Merging them, I get:

dm.merge(nil, attrs)
 => {"merge!"=>#<Chef::Node::Attribute:0x000001017b8cf0 @attribute={"fotonauts"=>{"balancers"=>{"search_server_host"=>"search."}}}, 
@auto_vivifiy_on_read=false, @current_attribute={"search_server_host"=>"search."}, @current_default={}, @current_override={}, 
@default={"fotonauts"=>{"balancers"=>{}}}, @has_been_read=false, @override={}, @set_unless_value_present=false, @state=["fotonauts", :balancers, 
"search_server_host"]>, "internal"=>false}

I'd appreciate if you can verify the fix with a recent version of chef. You can install the beta/prerelease versions of chef with gem install chef --pre If you can still reproduce, please re-open the ticket and I'll have another look. Thanks.

Show
Daniel DeLeo added a comment - 15/Jun/10 6:24 AM Hi Pierre, I cannot reproduce this now, I think it may have been incidentally fixed by another patch, possibly CHEF-1246. Loading your data I get:
attrs = YAML.load_file('test.yml')
 => {"merge!"=>#<Chef::Node::Attribute:0x00000102844fb0 @attribute={"fotonauts"=>{"balancers"=>{"search_server_host"=>"search."}}},
@auto_vivifiy_on_read=false, @current_attribute={"search_server_host"=>"search."}, @current_default={}, @current_override={}, 
@default={"fotonauts"=>{"balancers"=>{}}}, @has_been_read=false, @override={}, @set_unless_value_present=false, @state=["fotonauts", :balancers, 
"search_server_host"]>, "internal"=>false}
Merging them, I get:
dm.merge(nil, attrs)
 => {"merge!"=>#<Chef::Node::Attribute:0x000001017b8cf0 @attribute={"fotonauts"=>{"balancers"=>{"search_server_host"=>"search."}}}, 
@auto_vivifiy_on_read=false, @current_attribute={"search_server_host"=>"search."}, @current_default={}, @current_override={}, 
@default={"fotonauts"=>{"balancers"=>{}}}, @has_been_read=false, @override={}, @set_unless_value_present=false, @state=["fotonauts", :balancers, 
"search_server_host"]>, "internal"=>false}
I'd appreciate if you can verify the fix with a recent version of chef. You can install the beta/prerelease versions of chef with gem install chef --pre If you can still reproduce, please re-open the ticket and I'll have another look. Thanks.

People

Vote (0)
Watch (0)

Dates

  • Created:
    21/May/10 2:54 PM
    Updated:
    15/Jun/10 6:24 AM
    Resolved:
    15/Jun/10 6:24 AM