-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bricks_waiting_to_join - undefined method `empty?' for nil:NilClass #60
Comments
That attribute is defined at https://github.com/shortdudey123/chef-gluster/blob/master/recipes/server_extend.rb#L21 and that code being skipped most likely means 1 of 2 things: 1) Can you confirm if one of these is true? I am thinking that code needs to be moved outside the |
Hi @shortdudey123, I'm sorry, but I attached my my role settings. "gluster": {
"version": "3.7",
"server": {
"peer_retries": 10,
"peer_retry_delay": 60,
"disks": [
"/dev/xvdb"
],
"brick_mount_path": "/data",
"volumes": {
"gv0": {
"peers": [
"gluster-01.example.org",
"gluster-02.example.org",
"gluster-03.example.org",
"gluster-04.example.org"
],
"replica_count": 2,
"volume_type": "distributed-replicated",
"size": "10G",
"bricks_waiting_to_join": ""
}
} |
For me it looks like https://github.com/shortdudey123/chef-gluster/blob/master/recipes/server_extend.rb#L20-L22 isn't working correctly. My fix for this error would be this. diff --git a/recipes/server_extend.rb b/recipes/server_extend.rb
index 65e4e4e..7201939 100644
--- a/recipes/server_extend.rb
+++ b/recipes/server_extend.rb
@@ -17,10 +17,6 @@ node['gluster']['server']['volumes'].each do |volume_name, volume_values|
next
end
- unless node.default['gluster']['server']['volumes'][volume_name].attribute?('bricks_waiting_to_join')
- node.default['gluster']['server']['volumes'][volume_name]['bricks_waiting_to_join'] = ''
- end
-
peer_bricks = chef_node['gluster']['server']['volumes'][volume_name]['bricks'].select { |brick| brick.include? volume_name }
brick_count += (peer_bricks.count || 0)
peer_bricks.each do |brick|
@@ -37,7 +33,7 @@ node['gluster']['server']['volumes'].each do |volume_name, volume_values|
end
replica_count = volume_values['replica_count']
- next if node['gluster']['server']['volumes'][volume_name]['bricks_waiting_to_join'].empty?
+ next unless node['gluster']['server']['volumes'][volume_name].attribute?('bricks_waiting_to_join')
# The number of bricks in bricks_waiting_to_join has to be a modulus of the replica_count we are using for our gluster volume
if (brick_count % replica_count) == 0
Chef::Log.info("Attempting to add new bricks into volume #{volume_name}")
|
You can't remove the initialization of it, otherwise other stuff will break (`node['gluster']['server']['volumes'][volume_name]['bricks_waiting_to_join'] would be nil when used later)
When the code gets to https://github.com/shortdudey123/chef-gluster/blob/master/recipes/server_extend.rb#L24, what is the value of |
Chef fails during the compiling phase, so at this time no code is executed and the variable is not set. ================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/gluster/recipes/server.rb
================================================================================ |
right but the exception happened at |
I know it's on line 40 😉 but I don't understand why it works at the first chef-run and then breaks. In my node attributes, if I use |
hmm thats true, let me do some testing and see if i can see what happening When you do the 2nd chef run, have all 4 nodes in the peers list successfully converged at least once? |
Yes they have. |
ok, i will try and work on trying to replicate this weekend |
Any updates here. :-) |
Have not had a chance to test. Will try and replicate this week |
Moving the initialisation code to just before peers.each block did indeed fix the problem for me. And functionally it is the same before, so should be safe to change. If you look a bit further up in your chef-client output, you should see a few "WARN: Unable to find a chef node for ..." just before the Recipe Compile Error. (At least that is the case for me). I think that part failed on subsequence runs because peers has been defined, but during the compile phrase Chef::Node.load does not actually run anything ( https://github.com/shortdudey123/chef-gluster/blob/master/recipes/server_extend.rb#L14 ). So the initialisation block is skipped. |
@vchung-nz make sense, can you open a PR with your fix? I think that would work better than the diff that @dpattmann has above, since that will keep it from being |
@dpattmann can you try out master? should be good now |
@shortdudey123 LGTM 😄 👍 |
cool :) |
Hi,
after the first chef-run I get this error message from my chef-client. (12.7.2)
I fixed this error by setting
bricks_waiting_to_join
for each volume to''
, but it looks like a bug 🐛The text was updated successfully, but these errors were encountered: