diff --git a/broker/conf/broker.conf b/broker/conf/broker.conf index 9e5bb7d1f4..c302635032 100644 --- a/broker/conf/broker.conf +++ b/broker/conf/broker.conf @@ -217,6 +217,12 @@ DEFAULT_REGION_NAME="" # Allow region selection when creating applications. Default is true ALLOW_REGION_SELECTION="true" +# Minimum Node Disk Buffer Percentage +# +# When moving a gear to a new node, ensure that after a move this percentage +# of free disk space will remain on the new node. +MIN_NODE_DISK_BUFFER="5" + # Normalize logins / usernames according to specified method(s) in OpenShift::Username; # e.g. when set to "lowercase", a user logging in as "JDoe" is the same as "jdoe". # WARNING: nothing is done automatically to update existing non-normalized logins, diff --git a/broker/config/environments/development.rb b/broker/config/environments/development.rb index 3667476854..6418d77ed5 100644 --- a/broker/config/environments/development.rb +++ b/broker/config/environments/development.rb @@ -123,6 +123,7 @@ :app_advertise_https => conf.get_bool("APP_ADVERTISE_HTTPS", false), :auth_user_lookup_only => conf.get_bool("AUTH_USER_LOOKUP_ONLY", false), :auth_user_lookup_fail_msg => conf.get("AUTH_USER_LOOKUP_FAIL_MESSAGE", "This cluster is configured for user lookup only. Please contact your system administrator for provisioning your user account."), + :min_node_disk_buffer => (conf.get("MIN_NODE_DISK_BUFFER", "5")).to_i } config.auth = { diff --git a/broker/config/environments/production.rb b/broker/config/environments/production.rb index 10231c2278..8ab130115c 100644 --- a/broker/config/environments/production.rb +++ b/broker/config/environments/production.rb @@ -112,6 +112,7 @@ :app_advertise_https => conf.get_bool("APP_ADVERTISE_HTTPS", false), :auth_user_lookup_only => conf.get_bool("AUTH_USER_LOOKUP_ONLY", false), :auth_user_lookup_fail_msg => conf.get("AUTH_USER_LOOKUP_FAIL_MESSAGE", "This cluster is configured for user lookup only. Please contact your system administrator for provisioning your user account."), + :min_node_disk_buffer => (conf.get("MIN_NODE_DISK_BUFFER", "5")).to_i } config.auth = { diff --git a/broker/config/environments/test.rb b/broker/config/environments/test.rb index 706ace7cd1..1fed0ac489 100644 --- a/broker/config/environments/test.rb +++ b/broker/config/environments/test.rb @@ -121,6 +121,7 @@ :app_advertise_https => conf.get_bool("APP_ADVERTISE_HTTPS", false), :auth_user_lookup_only => conf.get_bool("AUTH_USER_LOOKUP_ONLY", false), :auth_user_lookup_fail_msg => conf.get("AUTH_USER_LOOKUP_FAIL_MESSAGE", "This cluster is configured for user lookup only. Please contact your system administrator for provisioning your user account."), + :min_node_disk_buffer => (conf.get("MIN_NODE_DISK_BUFFER", "5")).to_i } config.auth = { diff --git a/plugins/msg-broker/mcollective/lib/openshift/mcollective_application_container_proxy.rb b/plugins/msg-broker/mcollective/lib/openshift/mcollective_application_container_proxy.rb index a484bc3098..c852c963c8 100755 --- a/plugins/msg-broker/mcollective/lib/openshift/mcollective_application_container_proxy.rb +++ b/plugins/msg-broker/mcollective/lib/openshift/mcollective_application_container_proxy.rb @@ -2413,11 +2413,13 @@ def rsync_destination_container(gear, destination_container, destination_distric log_debug "DEBUG: Gear platform is '#{platform}'" destination_avail_space = destination_container.get_node_disk_free destination_total_space = destination_container.get_node_total_size + min_node_disk_buffer = Rails.application.config.openshift[:min_node_disk_buffer].to_f # check here to make sure addition of gear to destination_container # will not result in > 95% full destination_container - if (destination_avail_space - source_used_blocks.to_f)/destination_total_space < 0.05 - raise OpenShift::NodeUnavailableException.new("Gear '#{gear.uuid}' cannot be moved to '#{destination_container.id}'. Not enough disk space, node would be > 95% full after move.", 140) + if (destination_avail_space - source_used_blocks.to_f)/destination_total_space < (min_node_disk_buffer/100) + max_percentage = sprintf('%.0f', 100 - min_node_disk_buffer) + raise OpenShift::NodeUnavailableException.new("Gear '#{gear.uuid}' cannot be moved to '#{destination_container.id}'. Not enough disk space, node would be > #{max_percentage}% full after move.", 140) end log_debug "DEBUG: Creating new account for gear '#{gear.uuid}' on #{destination_container.id}"