Skip to content

Commit

Permalink
Increase system wide fd limit for controller to 165k
Browse files Browse the repository at this point in the history
Change-Id: I474d1956ea821ebd4420cb0962aa6f24fb586300
Closes-Bug: #1582100
(cherry picked from commit 12c4cd1)
  • Loading branch information
Megh Bhatt committed May 24, 2016
1 parent 3d22453 commit 4aa6010
Showing 1 changed file with 3 additions and 67 deletions.
70 changes: 3 additions & 67 deletions fabfile/tasks/helpers.py
Expand Up @@ -1041,6 +1041,7 @@ def increase_limits():
Increase limits in /etc/security/limits.conf, sysctl.conf and /etc/contrail/supervisor*.conf files
'''
execute('increase_limits_node', env.host_string)
#end increase_limits

@task
def increase_limits_node(*args):
Expand Down Expand Up @@ -1072,44 +1073,10 @@ def increase_limits_node(*args):

sysctl_conf = '/etc/sysctl.conf'
insert_line_to_file(pattern = '^fs.file-max.*',
line = 'fs.file-max = 65535',file_name = sysctl_conf)
line = 'fs.file-max = 165535',file_name = sysctl_conf)
sudo('sysctl -p')

sudo('sed -i \'s/^minfds.*/minfds=10240/\' /etc/contrail/supervisor*.conf')


limits_conf = '/etc/security/limits.conf'
with settings(warn_only = True):
pattern='^root\s*soft\s*nproc\s*.*'
if detect_ostype() in ['ubuntu']:
line = 'root soft nofile 65535\nroot hard nofile 65535'
else:
line = 'root soft nproc 65535'
insert_line_to_file(pattern = pattern, line = line,file_name = limits_conf)

pattern='^*\s*hard\s*nofile\s*.*'
line = '* hard nofile 65535'
insert_line_to_file(pattern = pattern, line = line,file_name = limits_conf)

pattern='^*\s*soft\s*nofile\s*.*'
line = '* soft nofile 65535'
insert_line_to_file(pattern = pattern, line = line,file_name = limits_conf)

pattern='^*\s*hard\s*nproc\s*.*'
line = '* hard nproc 65535'
insert_line_to_file(pattern = pattern, line = line,file_name = limits_conf)

pattern='^*\s*soft\s*nproc\s*.*'
line = '* soft nofile 65535'
insert_line_to_file(pattern = pattern, line = line,file_name = limits_conf)

sysctl_conf = '/etc/sysctl.conf'
insert_line_to_file(pattern = '^fs.file-max.*',
line = 'fs.file-max = 65535',file_name = sysctl_conf)
sudo('sysctl -p')

sudo('sed -i \'s/^minfds.*/minfds=10240/\' /etc/contrail/supervisor*.conf')

#end increase_limits

@roles('cfgm','database','collector')
Expand All @@ -1118,38 +1085,7 @@ def increase_limits_no_control():
'''
Increase limits in /etc/security/limits.conf, sysctl.conf and /etc/contrail/supervisor*.conf files
'''
limits_conf = '/etc/security/limits.conf'
with settings(warn_only = True):
pattern='^root\s*soft\s*nproc\s*.*'
if detect_ostype() in ['ubuntu']:
line = 'root soft nofile 65535\nroot hard nofile 65535'
else:
line = 'root soft nproc 65535'
insert_line_to_file(pattern = pattern, line = line,file_name = limits_conf)

pattern='^*\s*hard\s*nofile\s*.*'
line = '* hard nofile 65535'
insert_line_to_file(pattern = pattern, line = line,file_name = limits_conf)

pattern='^*\s*soft\s*nofile\s*.*'
line = '* soft nofile 65535'
insert_line_to_file(pattern = pattern, line = line,file_name = limits_conf)

pattern='^*\s*hard\s*nproc\s*.*'
line = '* hard nproc 65535'
insert_line_to_file(pattern = pattern, line = line,file_name = limits_conf)

pattern='^*\s*soft\s*nproc\s*.*'
line = '* soft nofile 65535'
insert_line_to_file(pattern = pattern, line = line,file_name = limits_conf)

sysctl_conf = '/etc/sysctl.conf'
insert_line_to_file(pattern = '^fs.file-max.*',
line = 'fs.file-max = 65535',file_name = sysctl_conf)
sudo('sysctl -p')

sudo('sed -i \'s/^minfds.*/minfds=10240/\' /etc/contrail/supervisor*.conf')

execute('increase_limits_node', env.host_string)
#end increase_limits_no_control

def insert_line_to_file(line,file_name,pattern=None):
Expand Down

0 comments on commit 4aa6010

Please sign in to comment.