Skip to content

Commit

Permalink
Minimum diskGB varialbe should not be enforced, should assume
Browse files Browse the repository at this point in the history
that the mimimum requirement for 256GB, if the requirement is not met,
enforce setting the variable in testbed.py.
Closes-Bug: 1460757

Change-Id: Id4b9580d39808ed2e30c985be4e6add7b7d0814a
  • Loading branch information
cijohnson committed Jun 3, 2015
1 parent 637303e commit 87af1a4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
25 changes: 21 additions & 4 deletions fabfile/tasks/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import datetime
from fabfile.tasks.esxi_defaults import apply_esxi_defaults
from fabfile.utils.cluster import get_ntp_server
from fabfile.utils.analytics import get_analytics_data_dir, get_minimum_diskGB

@task
@parallel
Expand Down Expand Up @@ -1136,15 +1137,31 @@ def delete_cassandra_db_files():
sudo('rm -rf %s/saved_caches' %(db_path))


@task
@EXECUTE_TASK
@roles('database')
def check_disk_space():
data_dir = get_analytics_data_dir()
if not exists(data_dir, use_sudo=True):
return True
disk_cmd = "df -Pk " + data_dir + " | grep % | awk '{print $2}'"
total_disk = sudo(disk_cmd)
if (int(total_disk)/(1024*1024) < int(get_minimum_diskGB())):
return False
return True

@task
@roles('build')
def pre_check():
db = getattr(testbed, 'minimum_diskGB', None)
if not db:
print "\nERROR: Minimum disk space for analytics db is not set in testbed.py"
result = execute('check_disk_space')
nodes_without_minimum_space = filter(lambda node: node != None,
map(lambda (node, met): node if not met else None, result.items()))
if nodes_without_minimum_space:
print "\nERROR: Minimum disk space(256GB) for analytics db is not met in nodes: %s"\
% nodes_without_minimum_space
print "\tPlease set 'minimum_diskGB' in testbed.py and continue."
print "\tSpecifiy the avalilable disk space of database node in GB"
print "\tRecommended to use a database node with 256GB disk."
print "\tHowever minimum disk space for database node is 256GB."
exit(1)
database_nodes = deepcopy(env.roledefs['database'])
if (len(database_nodes) % 2) != 1:
Expand Down
5 changes: 3 additions & 2 deletions fabfile/utils/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def get_database_dir():
return getattr(testbed, 'database_dir', None)

def get_analytics_data_dir():
return getattr(testbed, 'analytics_data_dir', None)
return getattr(testbed, 'analytics_data_dir',
'/var/lib/cassandra/data')

def get_ssd_data_dir():
return getattr(testbed, 'ssd_data_dir', None)
Expand All @@ -46,7 +47,7 @@ def get_analytics_flow_ttl():
#end get_analytics_flow_ttl

def get_minimum_diskGB():
return getattr(testbed, 'minimum_diskGB', None)
return getattr(testbed, 'minimum_diskGB', '256')
#end get_analytics_flow_ttl

def get_kafka_enabled():
Expand Down

0 comments on commit 87af1a4

Please sign in to comment.