Skip to content

Commit

Permalink
Remove code that modifies supervisor configuration to change fd limit
Browse files Browse the repository at this point in the history
to 10240 since that changes cassandra fd limit from the recommended
value of 100000. Related changes have been done in the controller and
packaging repos to instead have the other supervisor configuration files
be installed with the 10240 fd limits.
Closes-Bug: #1501960

Change-Id: I3698ff0f7dd6e94987649d65ea87ea3d78ac75bb
  • Loading branch information
Megh Bhatt committed Oct 5, 2015
1 parent 7d9a1f2 commit 296d570
Showing 1 changed file with 7 additions and 84 deletions.
91 changes: 7 additions & 84 deletions fabfile/tasks/helpers.py
Expand Up @@ -1013,6 +1013,7 @@ def increase_ulimits():
Increase ulimit in /etc/init.d/mysqld /etc/init/mysql.conf /etc/init.d/rabbitmq-server files
'''
execute('increase_ulimits_node', env.host_string)
#end increase_ulimits

@task
def increase_ulimits_node(*args):
Expand All @@ -1028,27 +1029,16 @@ def increase_ulimits_node(*args):
sudo("sed -i '/start(){/ a\ ulimit -n 10240' /etc/init.d/mysqld")
sudo("sed -i '/start_rabbitmq () {/a\ ulimit -n 10240' /etc/init.d/rabbitmq-server")
sudo("sed -i '/\[mysqld\]/a\max_connections = 2048' /etc/my.cnf")


with settings(warn_only = True):
if detect_ostype() == 'ubuntu':
sudo("sed -i '/start|stop)/ a\ ulimit -n 10240' /etc/init.d/mysql")
sudo("sed -i '/start_rabbitmq () {/a\ ulimit -n 10240' /etc/init.d/rabbitmq-server")
sudo("sed -i '/umask 007/ a\limit nofile 10240 10240' /etc/init/mysql.conf")
sudo("sed -i '/\[mysqld\]/a\max_connections = 10000' /etc/mysql/my.cnf")
sudo("echo 'ulimit -n 10240' >> /etc/default/rabbitmq-server")
else:
sudo("sed -i '/start(){/ a\ ulimit -n 10240' /etc/init.d/mysqld")
sudo("sed -i '/start_rabbitmq () {/a\ ulimit -n 10240' /etc/init.d/rabbitmq-server")
sudo("sed -i '/\[mysqld\]/a\max_connections = 2048' /etc/my.cnf")
#end increase_ulimits_node

@roles('cfgm','database','control','collector')
@task
def increase_limits():
'''
Increase limits in /etc/security/limits.conf, sysctl.conf and /etc/contrail/supervisor*.conf files
Increase limits in /etc/security/limits.conf, and sysctl.conf
'''
execute('increase_limits_node', env.host_string)
#end increase_limits

@task
def increase_limits_node(*args):
Expand Down Expand Up @@ -1082,82 +1072,15 @@ def increase_limits_node(*args):
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')


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
#end increase_limits_node

@roles('cfgm','database','collector')
@task
def increase_limits_no_control():
'''
Increase limits in /etc/security/limits.conf, sysctl.conf and /etc/contrail/supervisor*.conf files
Increase limits in /etc/security/limits.conf, and sysctl.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')

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 296d570

Please sign in to comment.