basho-labs/riak-chef-cookbook

Riak fails to start if hostname is not a fqdn

Closed this issue · 1 comments

Ran into this testing on digital ocean:

[2014-10-11T16:58:47-04:00] ERROR: service[riak] (riak::default line 97) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [
0], but received '1'
---- Begin output of /etc/init.d/riak start ----
STDOUT: Node 'riak@defaultubuntu14-cheeseplus-zebra-6g9ko3h' not responding to pings.
riak failed to start within 15 seconds,
see the output of 'riak console' for more information.
If you want to wait longer, set the environment variable
WAIT_FOR_ERLANG to the number of seconds to wait.
STDERR:
---- End output of /etc/init.d/riak start ----

The easy solution is to just do what the basho/riak-cs-chef-cookbook does and use node['ipaddress'] to form the Erlang node name. The other option is doing something like this in the recipe.

# validate the fqdn and if probalo then use IP address
unless /(?=^.{4,255}$)(^((?!-)[a-zA-Z0-9-]{1,63}(?<!-)\.)+[a-zA-Z]{2,63}$)/.match("#{node['fqdn']}")
  node.default['riak']['args']['-name'] = "riak@#{node['ipaddress']}"
end

I know using regexes to validate domains is generally a Bad Thing™ to do the but the above seems to work in testing. Opinions?

Great suggestion to make it easier to read from #chef irc

valid_fqdn_regexp = /(?=^.{4,255}$)(^((?!-)[a-zA-Z0-9-]{1,63}(?<!-)\.)+[a-zA-Z]{2,63}$)/

unless valid_fqdn_regexp.match("#{node['fqdn']}")
  node.default['riak']['args']['-name'] = "riak@#{node['ipaddress']}"
end