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 2ed3fa6
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
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 @@ -39,3 +39,7 @@ NODE_RSYNC_ADDRESS="ip_address"
# can be moved if a gear is over quota limits, up to this quota multiplier.
QUOTA_BLOCKS_BUFFER=1.2
QUOTA_INODES_BUFFER=1.2

# Node disk free space buffer. This will ensure that gears will only be moved to
# nodes that will have at least this amount of free disk space buffer after the move.
NODE_DF_BUFFER=0.05
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
:node_profile_enabled => conf.get_bool("NODE_PROFILE_ENABLED", "false"),
:node_rsync_address => conf.get("NODE_RSYNC_ADDRESS", "ip_address"),
:quota_blocks_buffer => conf.get("QUOTA_BLOCKS_BUFFER", 1.2),
:quota_inodes_buffer => conf.get("QUOTA_INODES_BUFFER", 1.2)
:quota_inodes_buffer => conf.get("QUOTA_INODES_BUFFER", 1.2),
:node_df_buffer => conf.get("NODE_DF_BUFFER", 0.05)
}
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def initialize(id, district=nil, blocks_multiplier=1, inodes_multiplier=1)
inodes_multiplier=Rails.configuration.msg_broker[:quota_inodes_buffer]
@blocks_multiplier = blocks_multiplier
@inodes_multiplier = inodes_multiplier
node_df_buffer=Rails.configuration.msg_broker[:node_df_buffer]
@node_df_buffer = node_df_buffer
@id = id
@district = district
@disable_print_debug = false
Expand Down Expand Up @@ -816,6 +818,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 +2429,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

# 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("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 2ed3fa6

Please sign in to comment.