Skip to content

Commit

Permalink
if user specifies a string then we will set the value as string
Browse files Browse the repository at this point in the history
e.g "10GB" but if user specifies an integer then we will set the
disk free limit to the value that user has set

there is no additional validation done here so if the user passes
a value that is beyond what system resources can accomodate it can
cause issues in production but we dont check the value against
the system resources

tests:

modified the disk_free_limit to both int and string and
confirmed that etc/rabbitmq/rabbitmq.config reflects the value
set.

    {log_levels, [{ connection, info }]},
    {disk_free_limit, 10000000},

or

    {log_levels, [{ connection, info }]},
    {disk_free_limit, "10GB"},

chef 12.7 output

  * template[/etc/rabbitmq/rabbitmq.config] action create
    - update content in file /etc/rabbitmq/rabbitmq.config from 08a317 to 75ef07
    - suppressed sensitive resource
  • Loading branch information
farshidce committed Feb 29, 2016
1 parent 6c18ee5 commit ed7ebcd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@

# resource usage
default['rabbitmq']['disk_free_limit_relative'] = nil
default['rabbitmq']['disk_free_limit'] = nil
default['rabbitmq']['vm_memory_high_watermark'] = nil
default['rabbitmq']['max_file_descriptors'] = 1024
default['rabbitmq']['open_file_limit'] = nil
Expand Down
7 changes: 7 additions & 0 deletions templates/default/rabbitmq.config.erb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@
<% if node['rabbitmq']['disk_free_limit_relative'] -%>
{disk_free_limit, {mem_relative, <%= node['rabbitmq']['disk_free_limit_relative'] %>}},
<% end %>
<% if node['rabbitmq']['disk_free_limit'] %>
<% if node['rabbitmq']['disk_free_limit'].is_a? String %>
{disk_free_limit, "<%= node['rabbitmq']['disk_free_limit'] %>"},
<%elsif node['rabbitmq']['disk_free_limit'].is_a? Integer %>
{disk_free_limit, <%= node['rabbitmq']['disk_free_limit'] %>},
<% end %>
<% end %>
<% if node['rabbitmq']['vm_memory_high_watermark'] -%>
{vm_memory_high_watermark, <%= node['rabbitmq']['vm_memory_high_watermark'] %>},
<% end %>
Expand Down

0 comments on commit ed7ebcd

Please sign in to comment.