Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

Commit

Permalink
make node buffer configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
sallyom committed Jul 28, 2016
1 parent c3c1eb9 commit 7ecb9a0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
7 changes: 7 additions & 0 deletions node/conf/resource_limits.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ node_profile=small
# For no over-commit, should be (Total System Memory - 1G) / memory_limit_in_bytes
max_active_gears=60

# Node disk buffer
#
# When moving a gear to a node, ensure that after a move this buffer of free disk space
# will be left on the destination node.
node_df_buffer=0.05

# no_overcommit_active enforces max_active_gears in a more stringent manner than normal,
# however it also adds overhead to gear creation, so should only be set to true
# when needed, like in the case of enforcing single tenancy on a node.
Expand Down Expand Up @@ -136,3 +142,4 @@ limits_nproc=250 # max number of processes
[cg_template_boosted]
cpu_shares=256
cpu_cfs_quota_us=200000

3 changes: 3 additions & 0 deletions node/lib/openshift-origin-node/model/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Node < Model
DEFAULT_QUOTA_FILES = '80000'
DEFAULT_NO_OVERCOMMIT_ACTIVE = false
DEFAULT_MAX_ACTIVE_GEARS = 0
DEFAULT_NODE_DF_BUFFER = 0.05

@@resource_limits_cache = nil

Expand Down Expand Up @@ -336,6 +337,8 @@ def self.node_utilization

# use max_{active_,}gears if set in resource limits, or fall back to old "apps" names
res['max_active_gears'] = (resource.get('max_active_gears') or resource.get('max_active_apps') or DEFAULT_MAX_ACTIVE_GEARS)
res['node_df_buffer'] = resource.get('node_df_buffer', DEFAULT_NODE_DF_BUFFER)


#
# Count number of git repos and gear status counts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,20 @@ def get_node_total_size
rpc_get_fact_direct('node_total_size').to_i
end

# <<accessor>>
# Get the disk free buffer of a Node
#
# RETURNS:
# * Float: the disk free buffer of a Node
#
# NOTES:
# * method on Node
# * calls rpc_get_fact_direct
#
def get_node_df_buffer
rpc_get_fact_direct('node_df_buffer').to_f
end

#
# Add a component to an existing gear on the node
#
Expand Down Expand Up @@ -2413,11 +2427,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
destination_df_buffer = destination_container.get_node_df_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 < destination_df_buffer
max_value = sprintf('%.0f', (1.0 - destination_df_buffer)*100)
raise OpenShift::NodeUnavailableException.new("DEST_DF_BUFFER: #{destination_df_buffer} Gear '#{gear.uuid}' cannot be moved to '#{destination_container.id}'. Not enough disk space, node would be using > #{max_value}% of it's disk space after the move.", 140)
end

log_debug "DEBUG: Creating new account for gear '#{gear.uuid}' on #{destination_container.id}"
Expand Down
1 change: 1 addition & 0 deletions plugins/msg-node/mcollective/facts/openshift_facts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def get_node_config_value(key, default)
Facter.add(:node_disk_free) { setcode { results['node_disk_free'] } }
Facter.add(:node_total_size) { setcode { results['node_total_size'] } }
Facter.add(:node_profile) { setcode { results['node_profile'] } }
Facter.add(:node_df_buffer) { setcode { results['node_df_buffer'] } }
Facter.add(:max_active_gears) { setcode { results['max_active_gears'] || '0' } }
Facter.add(:no_overcommit_active) { setcode { results['no_overcommit_active'] || false } }
Facter.add(:quota_blocks) { setcode { results['quota_blocks'] } }
Expand Down

0 comments on commit 7ecb9a0

Please sign in to comment.