From d2ac9b19ccd7fa930b4c1ff98cb04082687323e5 Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: Thu, 12 Oct 2017 11:44:59 +0200 Subject: [PATCH] haproxy: Check for existence of "content[:stick]" (bsc#1062889) After a cowbar-ha update, the 'stick' attribute introduced in commit #74115353 is missing from the existing node[:haproxy][sections] entries, which may result in errors such as: Chef::Mixin::Template::TemplateError ------------------------------------ undefined method `[]' for nil:NilClass This commit adds checks for the existence of the 'stick' attribute before dereferencing it. --- chef/cookbooks/haproxy/templates/default/haproxy.cfg.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chef/cookbooks/haproxy/templates/default/haproxy.cfg.erb b/chef/cookbooks/haproxy/templates/default/haproxy.cfg.erb index e64008f2..ebba8aa2 100644 --- a/chef/cookbooks/haproxy/templates/default/haproxy.cfg.erb +++ b/chef/cookbooks/haproxy/templates/default/haproxy.cfg.erb @@ -47,7 +47,7 @@ listen admin-stats <%= node[:haproxy][:stats][:enabled] ? node[:haproxy][:stats <% if content[:use_ssl] # http://www.haproxy.com/blog/maintain-affinity-based-on-ssl-session-id/ -%> # maximum SSL session ID length is 32 bytes. - stick-table type binary len 32 size 30k expire <%= content[:stick][:expire] %> + stick-table type binary len 32 size 30k expire <%= content[:stick] ? content[:stick][:expire] : "32m" %> acl clienthello req_ssl_hello_type 1 acl serverhello rep_ssl_hello_type 2 @@ -82,7 +82,7 @@ listen admin-stats <%= node[:haproxy][:stats][:enabled] ? node[:haproxy][:stats stick match req.cook(<%= cookie %>) <% end -%> <% end -%> - <% if content[:stick][:on] -%> + <% if content[:stick] && content[:stick][:on] && !content[:stick][:on].empty? -%> stick-table type ip size 1 stick on <%= content[:stick][:on] %> <% end -%>