Skip to content

Commit

Permalink
Update redis.conf on contrail upgrade
Browse files Browse the repository at this point in the history
- update lua-time-limit to 15000 milliseconds
- change fix_redis() to handle ubuntu and centos platforms

Change-Id: I1de9c11209eb449a24afd272654b9e154c74a307
Closes-Bug: #1459769
Related-Bug: #1463749
  • Loading branch information
Sundaresan Rajangam committed Jun 15, 2015
1 parent 504459c commit 7a3300a
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions contrail_provisioning/common/upgrade.py
Expand Up @@ -7,6 +7,7 @@
import os
import shutil
import argparse
from time import sleep

from fabric.api import local

Expand Down Expand Up @@ -173,12 +174,37 @@ def get_build(self, pkg='contrail-install-packages'):
return pkg_rel

def fix_redis(self):
if os.path.exists('/var/lib/redis/dump.rdb'):
os.remove('/var/lib/redis/dump.rdb')
conf_file = '/etc/redis/redis.conf'
local("sudo sed -i 's/^save 900 1/#save 900 1/g' %s" % conf_file)
local("sudo sed -i 's/^save 300 10/#save 300 10/g' %s" % conf_file)
local("sudo sed -i 's/^save 60 10000/#save 60 10000/g' %s" % conf_file)
if self.pdist in ['Ubuntu']:
redis_svc_name = 'redis-server'
redis_conf_file = '/etc/redis/redis.conf'
check_svc_started = True
else:
redis_svc_name = 'redis'
redis_conf_file = '/etc/redis.conf'
check_svc_started = False

local("sudo service %s stop" % (redis_svc_name))
# Set the lua-time-limit to 15000 milliseconds
local("sudo sed -i -e 's/lua-time-limit.*/lua-time-limit 15000/' %s" % (redis_conf_file))
# Disable persistence
dbfilename = local("sudo grep '^dbfilename' %s | awk '{print $2}'" % (redis_conf_file))
if dbfilename:
dbdir = local("sudo grep '^dir' %s | awk '{print $2}'" % (redis_conf_file))
if dbdir:
local("sudo rm -f %s/%s" % (dbdir, dbfilename))
local("sudo sed -i -e '/^[ ]*save/s/^/#/' %s" % (redis_conf_file))
local("sudo sed -i -e '/^[ ]*dbfilename/s/^/#/' %s" % (redis_conf_file))
local("sudo service %s start" % (redis_svc_name))
if check_svc_started:
# Check if the redis-server is running, if not, issue start again
count = 1
while local("sudo service %s status | grep not" % (redis_svc_name)).succeeded:
count += 1
if count > 10:
break
sleep(1)
local("sudo service %s restart" % (redis_svc_name))
# end fix_redis

def _upgrade(self):
self._backup_config()
Expand Down

0 comments on commit 7a3300a

Please sign in to comment.