Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sonic-buildimage : create new Redis DB instance and moving ASIC_DB to the new BD instance #2020

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions dockers/docker-database/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,38 @@ RUN apt-get autoclean -y
RUN apt-get autoremove -y
RUN rm -rf /debs ~/.cache

RUN sed -ri 's/^(save .*$)/# \1/g; \
s/^daemonize yes$/daemonize no/; \
s/^logfile .*$/logfile ""/; \
s/^# syslog-enabled no$/syslog-enabled no/; \
s/^# unixsocket/unixsocket/; \
RUN sed -ri 's/^(save .*$)/# \1/g; \
s/^daemonize yes$/daemonize no/; \
s/^logfile .*$/logfile ""/; \
s/^# syslog-enabled no$/syslog-enabled no/; \
s/^client-output-buffer-limit pubsub [0-9]+mb [0-9]+mb [0-9]+/client-output-buffer-limit pubsub 0 0 0/ \
' /etc/redis/redis.conf


RUN cp /etc/redis/redis.conf /etc/redis/redis-secondary.conf
RUN cp /etc/redis/redis.conf /etc/redis/redis-server.conf
RUN mkdir /var/lib/redis/redis-server
RUN mkdir /var/lib/redis/redis-secondary

RUN sed -ri 's/^# unixsocket .*/unixsocket \/var\/run\/redis\/redis.sock/; \
s/dir .*/dir \/var\/lib\/redis\/redis-server/; \
s/pidfile .*/pidfile \/var\/run\/redis\/redis-server.pid/; \
' /etc/redis/redis-server.conf

RUN sed -ri 's/port 6379/port 6380/; \
s/^# unixsocket .*/unixsocket \/var\/run\/redis\/redis-secondary.sock/; \
s/dir .*/dir \/var\/lib\/redis\/redis-secondary/; \
s/pidfile .*/pidfile \/var\/run\/redis\/redis-secondary.pid/; \
' /etc/redis/redis-secondary.conf

RUN sed -ri 's/DAEMON_ARGS=.*/DAEMON_ARGS=\/etc\/redis\/\`basename ${0}\`.conf/; \
s/NAME=.*/NAME=`basename ${0}`/; \
s/DESC=.*/DESC=`basename ${0}`/; \
s/PIDFILE=.*/PIDFILE=$RUNDIR\/`basename ${0}`.pid/; \
' /etc/init.d/redis-server

RUN cp /etc/init.d/redis-server /etc/init.d/redis-secondary

COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["files/configdb-load.sh", "/usr/bin/"]

Expand Down
13 changes: 12 additions & 1 deletion dockers/docker-database/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,19 @@ autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog

[group:redis-servers]
programs=redis-server,redis-server-secondary

[program:redis-server]
command=/usr/bin/redis-server /etc/redis/redis.conf
command=/usr/bin/redis-server /etc/redis/redis-server.conf
priority=2
autostart=true
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog

[program:redis-server-secondary]
command=/usr/bin/redis-server /etc/redis/redis-secondary.conf
priority=2
autostart=true
autorestart=false
Expand Down
4 changes: 4 additions & 0 deletions files/build_templates/docker_image_ctl.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ function postStartAction()
until [[ $(/usr/bin/docker exec database redis-cli ping | grep -c PONG) -gt 0 ]]; do
sleep 1;
done

until [[ $(/usr/bin/docker exec database redis-cli -p 6380 ping | grep -c PONG) -gt 0 ]]; do
sleep 1;
done
{%- elif docker_container_name == "swss" %}
docker exec swss rm -f /ready # remove cruft
if [[ -d /host/fast-reboot ]];
Expand Down
4 changes: 4 additions & 0 deletions files/scripts/configdb-load.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ until [[ $(redis-cli ping | grep -c PONG) -gt 0 ]]; do
sleep 1;
done

until [[ $(redis-cli -p 6380 ping | grep -c PONG) -gt 0 ]]; do
sleep 1;
done

# If there is a config db dump file, load it
if [ -r /etc/sonic/config_db.json ]; then
sonic-cfggen -j /etc/sonic/config_db.json --write-to-db
Expand Down
6 changes: 5 additions & 1 deletion files/scripts/swss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ start() {
do sleep 1;
done

until [[ $(/usr/bin/docker exec database redis-cli -p 6380 ping | grep -c PONG) -gt 0 ]];
do sleep 1;
done

# Wait for configDB initialization
until [[ $(/usr/bin/docker exec database redis-cli -n 4 GET "CONFIG_DB_INITIALIZED") ]];
do sleep 1;
Expand All @@ -27,7 +31,7 @@ start() {

# Flush DB
/usr/bin/docker exec database redis-cli -n 0 FLUSHDB
/usr/bin/docker exec database redis-cli -n 1 FLUSHDB
/usr/bin/docker exec database redis-cli -p 6380 -n 1 FLUSHDB
/usr/bin/docker exec database redis-cli -n 2 FLUSHDB
/usr/bin/docker exec database redis-cli -n 5 FLUSHDB
/usr/bin/docker exec database redis-cli -n 6 FLUSHDB
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function _docker_swss_check {
while true
do
# Check if syncd starts
result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli | sed -n 2p"` #TBD FIX ME
result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli -p 6380 | sed -n 2p"` #TBD FIX ME
if [ "$result" == "3" ]; then
return
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function _docker_swss_check {
while true
do
# Check if syncd starts
result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli | sed -n 2p"` #TBD FIX ME
result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli -p 6380 | sed -n 2p"` #TBD FIX ME
if [ "$result" == "3" ]; then
return
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function _docker_swss_check {
while true
do
# Check if syncd starts
result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli | sed -n 2p"` #TBD FIX ME
result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli -p 6380 | sed -n 2p"` #TBD FIX ME
if [ "$result" == "3" ]; then
return
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function _docker_swss_check {
while true
do
# Check if syncd starts
result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli | sed -n 2p"` #TBD FIX ME
result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli -p 6380 | sed -n 2p"` #TBD FIX ME
if [ "$result" == "3" ]; then
return
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function _docker_swss_check {
while true
do
# Check if syncd starts
result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli | sed -n 2p"` #TBD FIX ME
result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli -p 6380 | sed -n 2p"` #TBD FIX ME
if [ "$result" == "3" ]; then
return
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function _docker_swss_check {
while true
do
# Check if syncd starts
result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli | sed -n 2p"` #TBD FIX ME
result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli -p 6380 | sed -n 2p"` #TBD FIX ME
if [ "$result" == "3" ]; then
return
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function _docker_swss_check {
while true
do
# Check if syncd starts
result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli | sed -n 2p"` #TBD FIX ME
result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli -p 6380 | sed -n 2p"` #TBD FIX ME
if [ "$result" == "3" ]; then
return
fi
Expand Down
25 changes: 24 additions & 1 deletion platform/vs/docker-sonic-vs/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,34 @@ RUN sed -ri 's/^(save .*$)/# \1/g;
s/^daemonize yes$/daemonize no/; \
s/^logfile .*$/logfile ""/; \
s/^# syslog-enabled no$/syslog-enabled no/; \
s/^# unixsocket/unixsocket/; \
s/notify-keyspace-events ""/notify-keyspace-events AKE/; \
s/^client-output-buffer-limit pubsub [0-9]+mb [0-9]+mb [0-9]+/client-output-buffer-limit pubsub 0 0 0/ \
' /etc/redis/redis.conf

RUN cp /etc/redis/redis.conf /etc/redis/redis-secondary.conf
RUN cp /etc/redis/redis.conf /etc/redis/redis-server.conf
RUN mkdir /var/lib/redis/redis-server
RUN mkdir /var/lib/redis/redis-secondary

RUN sed -ri 's/^# unixsocket .*/unixsocket \/var\/run\/redis\/redis.sock/; \
s/dir .*/dir \/var\/lib\/redis\/redis-server/; \
s/pidfile .*/pidfile \/var\/run\/redis\/redis-server.pid/; \
' /etc/redis/redis-server.conf

RUN sed -ri 's/port 6379/port 6380/; \
s/^# unixsocket .*/unixsocket \/var\/run\/redis\/redis-secondary.sock/; \
s/dir .*/dir \/var\/lib\/redis\/redis-secondary/; \
s/pidfile .*/pidfile \/var\/run\/redis\/redis-secondary.pid/; \
' /etc/redis/redis-secondary.conf

RUN sed -ri 's/DAEMON_ARGS=.*/DAEMON_ARGS=\/etc\/redis\/\`basename ${0}\`.conf/; \
s/NAME=.*/NAME=`basename ${0}`/; \
s/DESC=.*/DESC=`basename ${0}`/; \
s/PIDFILE=.*/PIDFILE=$RUNDIR\/`basename ${0}`.pid/; \
' /etc/init.d/redis-server

RUN cp /etc/init.d/redis-server /etc/init.d/redis-secondary

COPY ["50-default.conf", "/etc/rsyslog.d/"]
COPY ["start.sh", "orchagent.sh", "/usr/bin/"]
COPY ["brcm.profile.ini", "/usr/share/sonic/device/vswitch/"]
Expand Down
4 changes: 3 additions & 1 deletion platform/vs/docker-sonic-vs/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ supervisorctl start rsyslogd

mkdir -p /var/run/redis

supervisorctl start redis-server
supervisorctl start redis-servers:redis-server

supervisorctl start redis-servers:redis-server-secondary

/usr/bin/configdb-load.sh

Expand Down
13 changes: 12 additions & 1 deletion platform/vs/docker-sonic-vs/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,19 @@ autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog

[group:redis-servers]
programs=redis-server,redis-server-secondary

[program:redis-server]
command=/usr/bin/redis-server /etc/redis/redis.conf
command=/usr/bin/redis-server /etc/redis/redis-server.conf
priority=3
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog

[program:redis-server-secondary]
command=/usr/bin/redis-server /etc/redis/redis-secondary.conf
priority=3
autostart=false
autorestart=false
Expand Down
6 changes: 4 additions & 2 deletions platform/vs/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def pytest_addoption(parser):

class AsicDbValidator(object):
def __init__(self, dvs):
self.adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)
self.adb = swsscommon.DBConnector(1, dvs.redis_sec_sock, 0)

# get default dot1q vlan id
atbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_VLAN")
Expand Down Expand Up @@ -111,14 +111,16 @@ def __init__(self, name=None):
'neighsyncd',
'orchagent',
'portsyncd',
'redis-server',
'redis-servers:redis-server',
'redis-servers:redis-server-secondary',
'rsyslogd',
'syncd',
'teamsyncd',
'vlanmgrd',
'zebra']
self.mount = "/var/run/redis-vs"
self.redis_sock = self.mount + '/' + "redis.sock"
self.redis_sec_sock = self.mount + '/' + "redis-secondary.sock"
self.client = docker.from_env()

self.ctn = None
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-sairedis
2 changes: 1 addition & 1 deletion src/sonic-snmpagent
2 changes: 1 addition & 1 deletion src/sonic-swss
2 changes: 1 addition & 1 deletion src/sonic-swss-common
2 changes: 1 addition & 1 deletion src/sonic-utilities