bloomberg / zookeeper-cookbook

A set of Chef recipes for installing and configuring Apache Zookeeper.
Other
17 stars 17 forks source link

NoMethodError #25

Open gabnasr opened 8 years ago

gabnasr commented 8 years ago

Hi i'm trying this cookbook with a data bag like the one in the example but i'm getting this error and i don't know why

Recipe: zookeeper-cluster::default
  * poise_service_user[zookeeper] action create
    * group[zookeeper] action create (up to date)
    * user[zookeeper] action create (up to date)
     (up to date)
  * tickTime=2000
  initLimit=5
  syncLimit=2
  leaderServes=yes
  forceSync=no
  dataDir=/var/lib/zookeeper
  leaderPort=2888
  clientPort=2181
  electionPort=3888 action create

    ================================================================================
    Error executing action `create` on resource 'tickTime=2000
    initLimit=5
    syncLimit=2
    leaderServes=yes
    forceSync=no
    dataDir=/var/lib/zookeeper
    leaderPort=2888
    clientPort=2181
    electionPort=3888'
    ================================================================================

    NoMethodError
    -------------
    undefined method `next' for nil:NilClass

    Cookbook Trace:
    ---------------
    /var/chef/cache/cookbooks/zookeeper-cluster/libraries/zookeeper_config.rb:30:in `myid'
    /var/chef/cache/cookbooks/zookeeper-cluster/libraries/zookeeper_config.rb:59:in `block (3 levels) in <class:ZookeeperConfig>'
    /var/chef/cache/cookbooks/zookeeper-cluster/libraries/zookeeper_config.rb:58:in `block (2 levels) in <class:ZookeeperConfig>'
    /var/chef/cache/cookbooks/poise/files/halite_gem/poise/helpers/subcontext_block.rb:54:in `instance_eval'
    /var/chef/cache/cookbooks/poise/files/halite_gem/poise/helpers/subcontext_block.rb:54:in `subcontext_block'
    /var/chef/cache/cookbooks/poise/files/halite_gem/poise/helpers/notifying_block.rb:67:in `notifying_block'
    /var/chef/cache/cookbooks/zookeeper-cluster/libraries/zookeeper_config.rb:45:in `block in <class:ZookeeperConfig>'

    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/zookeeper-cluster/recipes/default.rb

     17: config = zookeeper_config node['zookeeper-cluster']['service_name'] do |r|
     18:   instance_name node['fqdn']
     19:   owner node['zookeeper-cluster']['service_user']
     20:   group node['zookeeper-cluster']['service_group']
     21: 
     22:   node['zookeeper-cluster']['config'].each_pair { |k, v| r.send(k, v) }
     23:   notifies :restart, "zookeeper_service[#{name}]", :delayed
     24: end
     25: 

    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/zookeeper-cluster/recipes/default.rb:17:in `from_file'

    zookeeper_config("zookeeper") do
      provider #<Class:0x00000004f0fd30>
      action [:create]
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      declared_type :zookeeper_config
      cookbook_name "zookeeper-cluster"
      recipe_name "default"
      instance_name "zookeeper01.blabla.biz"
      owner "zookeeper"
      group "zookeeper"
      path "/etc/zookeeper/zoo.properties"
      properties {"tickTime"=>2000, "initLimit"=>5, "syncLimit"=>2, "leaderServes"=>"yes", "forceSync"=>"no"}
      data_dir "/var/lib/zookeeper"
      leader_port 2888
      client_port 2181
      election_port 3888
    end

Running handlers:
[2016-03-01T09:08:40-05:00] ERROR: Running exception handlers
Running handlers complete
[2016-03-01T09:08:40-05:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 08 seconds
[2016-03-01T09:08:40-05:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2016-03-01T09:08:40-05:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-03-01T09:08:40-05:00] ERROR: tickTime=2000
initLimit=5
syncLimit=2
leaderServes=yes
forceSync=no
dataDir=/var/lib/zookeeper
leaderPort=2888
clientPort=2181
electionPort=3888 (zookeeper-cluster::default line 17) had an error: NoMethodError: undefined method `next' for nil:NilClass
[2016-03-01T09:08:40-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
johnbellone commented 8 years ago

It may not be as clear as it could be in the documentation. If you are following the instructions in the README you will notice that we mention the node['fqdn'] must be the exact names of the nodes inside of the data bag. This is because we utilize the index of the array of hosts to be the unique identifier for the ZK cluster.

gabnasr commented 8 years ago

Yeah i know, its exactly the same

sergiopena commented 8 years ago

+1

chuckinator0 commented 6 years ago

Thanks so much for writing this cookbook! I have a small clarifying question that is related to the node[‘fqdn’]part of the readme. Is this part supposed to be an array of hostnames, like node[‘ip’,’another ip’,’yet another ip’] that matches what’s in the data bag item? It would be helpful if the readme showed the completed code based onthe example data bag file rather than the placeholder ‘fqdn’.

I’m using this cookbook in conjunction with the related kafka-cluster cookbook, so I also have the same question about the analogous broker_id line that uses rpartition to assign the last place value of the IP address to the broker ID. The rpartition function takes a single string, not an array of strings. I’m just confused on the syntax here and it would help to see a fully fleshed out example. Thanks!

whschultz commented 6 years ago

@chuckinator0 - I suspect you've figured this out by now, but I'm posting this because I hadn't, and it might help the next person that comes along starting from scratch with Chef:

The syntax is exactly as specified. Copy and past those four lines exactly as they are into your recipe. You'll need nothing else in the recipe file itself (unless you want more -- also, see the last paragraph regarding the attributes file for your recipe).

What's implied is that you need an "fqdn" attribute included in the JSON configuration file for your node (if you've gotten far enough to try to run this, you should already have this file). That will contain just the FQDN for that specific node. In order for the recipe to know about your other nodes, you'll need to create a databag named "zookeeper" with an array of those FQDNs specified for your environment (See the example JSON at the very bottom of the README). If you haven't already, this means you'll have to setup an environment and assign that environment to your node.

Lastly, you might also want to create your own attributes file for your own recipe. See the provide attributes file for all of the supported options. You may want to set the specific version that gets downloaded, so you'll want to copy the three service attributes from lines 21-23 to your recipe's attributes file.