Skip to content
Open
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
10 changes: 5 additions & 5 deletions dockers/docker-database/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ ENV DEBIAN_FRONTEND=noninteractive
# Update apt's cache of available packages
RUN apt-get update

# Install redis-server
RUN apt-get install -y redis-tools redis-server
# Install valkey-server
RUN apt-get install -y valkey-tools valkey-server

# Install click for CLI
RUN pip3 install click
Expand All @@ -25,17 +25,17 @@ RUN pip3 install click
{{ install_debian_packages(docker_database_debs.split(' ')) }}
{%- endif %}

# Configure redis settings
# Configure valkey settings
RUN sed -ri 's/^# save ""$/save ""/g; \
s/^daemonize yes$/daemonize no/; \
s/^logfile .*$/logfile ""/; \
s/^# syslog-enabled no$/syslog-enabled no/; \
s/^# unixsocket/unixsocket/; \
s/redis-server.sock/redis.sock/g; \
s/valkey-server.sock/valkey.sock/g; \
s/^client-output-buffer-limit pubsub [0-9]+mb [0-9]+mb [0-9]+/client-output-buffer-limit pubsub 0 0 0/; \
s/^notify-keyspace-events ""$/notify-keyspace-events AKE/; \
s/^databases [0-9]+$/databases 100/ \
' /etc/redis/redis.conf
' /etc/valkey/valkey.conf

COPY ["supervisord.conf.j2", "/usr/share/sonic/templates/"]
COPY ["critical_processes.j2", "/usr/share/sonic/templates/"]
Expand Down
58 changes: 29 additions & 29 deletions dockers/docker-database/database_config.json.j2
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{% set include_remote_db = (REMOTE_DB_IP is defined and REMOTE_DB_PORT is defined) %}
{
"INSTANCES": {
"redis":{
"valkey":{
"hostname" : "{{HOST_IP}}",
"port" : {{REDIS_PORT}},
"unix_socket_path" : "/var/run/redis{{DEV}}/redis.sock",
"unix_socket_path" : "/var/run/valkey{{DEV}}/valkey.sock",
"persistence_for_warm_boot" : "yes"
{% if DATABASE_TYPE is defined and DATABASE_TYPE != "" %}
,"database_type": "{{DATABASE_TYPE}}"
{% endif %}
},
"redis_chassis":{
"hostname" : "redis_chassis.server",
"valkey_chassis":{
"hostname" : "valkey_chassis.server",
"port": 6380,
"unix_socket_path": "/var/run/redis-chassis/redis_chassis.sock",
"unix_socket_path": "/var/run/valkey-chassis/valkey_chassis.sock",
"persistence_for_warm_boot" : "yes"
}
{% if include_remote_db %}
,"remote_redis":{
,"remote_valkey":{
"hostname" : "{{REMOTE_DB_IP}}",
"port" : {{REMOTE_DB_PORT}},
"unix_socket_path": "",
Expand All @@ -27,10 +27,10 @@
{% if DATABASE_TYPE is defined and DATABASE_TYPE == "dpudb" %}
{% else %}
,
"redis_bmp":{
"valkey_bmp":{
"hostname" : "{{HOST_IP}}",
"port" : {{BMP_DB_PORT}},
"unix_socket_path" : "/var/run/redis{{DEV}}/redis_bmp.sock",
"unix_socket_path" : "/var/run/valkey{{DEV}}/valkey_bmp.sock",
"persistence_for_warm_boot" : "yes"
}
{% endif %}
Expand All @@ -39,112 +39,112 @@
"APPL_DB" : {
"id" : 0,
"separator": ":",
"instance" : "redis"
"instance" : "valkey"
},
"ASIC_DB" : {
"id" : 1,
"separator": ":",
"instance" : "redis"
"instance" : "valkey"
},
"COUNTERS_DB" : {
"id" : 2,
"separator": ":",
"instance" : "redis"
"instance" : "valkey"
},
"LOGLEVEL_DB" : {
"id" : 3,
"separator": ":",
"instance" : "redis"
"instance" : "valkey"
},
"CONFIG_DB" : {
"id" : 4,
"separator": "|",
"instance" : "redis"
"instance" : "valkey"
},
"PFC_WD_DB" : {
"id" : 5,
"separator": ":",
"instance" : "redis"
"instance" : "valkey"
},
"FLEX_COUNTER_DB" : {
"id" : 5,
"separator": ":",
"instance" : "redis"
"instance" : "valkey"
},
"STATE_DB" : {
"id" : 6,
"separator": "|",
"instance" : "redis"
"instance" : "valkey"
},
"SNMP_OVERLAY_DB" : {
"id" : 7,
"separator": "|",
"instance" : "redis"
"instance" : "valkey"
},
"RESTAPI_DB" : {
"id" : 8,
"separator": "|",
"instance" : "redis"
"instance" : "valkey"
},
"GB_ASIC_DB" : {
"id" : 9,
"separator": ":",
"instance" : "redis"
"instance" : "valkey"
},
"GB_COUNTERS_DB" : {
"id" : 10,
"separator": ":",
"instance" : "redis"
"instance" : "valkey"
},
"GB_FLEX_COUNTER_DB" : {
"id" : 11,
"separator": ":",
"instance" : "redis"
"instance" : "valkey"
},
"CHASSIS_APP_DB" : {
"id" : 12,
"separator": "|",
"instance" : "redis_chassis"
"instance" : "valkey_chassis"
},
"CHASSIS_STATE_DB" : {
"id" : 13,
"separator": "|",
"instance" : "redis_chassis"
"instance" : "valkey_chassis"
},
"APPL_STATE_DB" : {
"id" : 14,
"separator": ":",
"instance" : "redis"
"instance" : "valkey"
}
{% if DATABASE_TYPE is defined and DATABASE_TYPE == "dpudb" %}
,
"DPU_APPL_DB" : {
"id" : 15,
"separator": ":",
"instance" : {% if include_remote_db %} "remote_redis" {% else %} "redis" {% endif %},
"instance" : {% if include_remote_db %} "remote_valkey" {% else %} "valkey" {% endif %},
"format": "proto"
},
"DPU_APPL_STATE_DB" : {
"id" : 16,
"separator": "|",
"instance" : {% if include_remote_db %} "remote_redis" {% else %} "redis" {% endif %}
"instance" : {% if include_remote_db %} "remote_valkey" {% else %} "valkey" {% endif %}
},
"DPU_STATE_DB" : {
"id" : 17,
"separator": "|",
"instance" : {% if include_remote_db %} "remote_redis" {% else %} "redis" {% endif %}
"instance" : {% if include_remote_db %} "remote_valkey" {% else %} "valkey" {% endif %}
},
"DPU_COUNTERS_DB" : {
"id" : 18,
"separator": ":",
"instance" : {% if include_remote_db %} "remote_redis" {% else %} "redis" {% endif %}
"instance" : {% if include_remote_db %} "remote_valkey" {% else %} "valkey" {% endif %}
}
{% else %}
,
"BMP_STATE_DB" : {
"id" : 20,
"separator": "|",
"instance" : "redis_bmp"
"instance" : "valkey_bmp"
}
{% endif %}
},
Expand Down
50 changes: 25 additions & 25 deletions dockers/docker-database/docker-database-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,27 @@ fi

export BMP_DB_PORT=6400

REDIS_DIR=/var/run/redis$NAMESPACE_ID
mkdir -p $REDIS_DIR/sonic-db
VALKEY_DIR=/var/run/valkey$NAMESPACE_ID
mkdir -p $VALKEY_DIR/sonic-db
mkdir -p /etc/supervisor/conf.d/

if [ -f /etc/sonic/database_config$NAMESPACE_ID.json ]; then
cp /etc/sonic/database_config$NAMESPACE_ID.json $REDIS_DIR/sonic-db/database_config.json
cp /etc/sonic/database_config$NAMESPACE_ID.json $VALKEY_DIR/sonic-db/database_config.json
else
if [ -f /etc/sonic/enable_multidb ]; then
HOST_IP=$host_ip REDIS_PORT=$redis_port DATABASE_TYPE=$DATABASE_TYPE BMP_DB_PORT=$BMP_DB_PORT j2 /usr/share/sonic/templates/multi_database_config.json.j2 > $REDIS_DIR/sonic-db/database_config.json
HOST_IP=$host_ip REDIS_PORT=$redis_port DATABASE_TYPE=$DATABASE_TYPE BMP_DB_PORT=$BMP_DB_PORT j2 /usr/share/sonic/templates/multi_database_config.json.j2 > $VALKEY_DIR/sonic-db/database_config.json
else
HOST_IP=$host_ip REDIS_PORT=$redis_port DATABASE_TYPE=$DATABASE_TYPE BMP_DB_PORT=$BMP_DB_PORT j2 /usr/share/sonic/templates/database_config.json.j2 > $REDIS_DIR/sonic-db/database_config.json
HOST_IP=$host_ip REDIS_PORT=$redis_port DATABASE_TYPE=$DATABASE_TYPE BMP_DB_PORT=$BMP_DB_PORT j2 /usr/share/sonic/templates/database_config.json.j2 > $VALKEY_DIR/sonic-db/database_config.json
fi
fi

# on VoQ system, we only publish redis_chassis instance and CHASSIS_APP_DB when
# on VoQ system, we only publish valkey_chassis instance and CHASSIS_APP_DB when
# either chassisdb.conf indicates starts chassis_db or connect to chassis_db,
# and redis_chassis instance is started in different container.
# and valkey_chassis instance is started in different container.
# in order to do that, first we save original database config file, then
# call update_chasissdb_config to remove chassis_db config from
# the original database config file and use the modified config file to generate
# supervisord config, so that we won't start redis_chassis service.
# supervisord config, so that we won't start valkey_chassis service.
# then we will decide to publish modified or original database config file based
# on the setting in chassisdb.conf
start_chassis_db=0
Expand All @@ -72,23 +72,23 @@ chassis_db_port=""
chassisdb_config="/usr/share/sonic/platform/chassisdb.conf"
[ -f $chassisdb_config ] && source $chassisdb_config

db_cfg_file="/var/run/redis/sonic-db/database_config.json"
db_cfg_file_tmp="/var/run/redis/sonic-db/database_config.json.tmp"
db_cfg_file="/var/run/valkey/sonic-db/database_config.json"
db_cfg_file_tmp="/var/run/valkey/sonic-db/database_config.json.tmp"
cp $db_cfg_file $db_cfg_file_tmp

if [[ $DATABASE_TYPE == "chassisdb" ]]; then
# Docker init for database-chassis
echo "Init docker-database-chassis..."
VAR_LIB_REDIS_CHASSIS_DIR="/var/lib/redis_chassis"
mkdir -p $VAR_LIB_REDIS_CHASSIS_DIR
VAR_LIB_VALKEY_CHASSIS_DIR="/var/lib/valkey_chassis"
mkdir -p $VAR_LIB_VALKEY_CHASSIS_DIR
update_chassisdb_config -j $db_cfg_file_tmp -k -p $chassis_db_port
# generate all redis server supervisord configuration file
# generate all valkey server supervisord configuration file
sonic-cfggen -j $db_cfg_file_tmp \
-t /usr/share/sonic/templates/supervisord.conf.j2,/etc/supervisor/conf.d/supervisord.conf \
-t /usr/share/sonic/templates/critical_processes.j2,/etc/supervisor/critical_processes
rm $db_cfg_file_tmp
chown -R redis:redis $VAR_LIB_REDIS_CHASSIS_DIR
chown -R redis:redis $REDIS_DIR
chown -R valkey:valkey $VAR_LIB_VALKEY_CHASSIS_DIR
chown -R valkey:valkey $VALKEY_DIR
exec /usr/local/bin/supervisord
exit 0
fi
Expand All @@ -97,9 +97,9 @@ fi
if [[ $NAMESPACE_ID == "" && $DATABASE_TYPE == "" && ( $NAMESPACE_COUNT -gt 1 || $NUM_DPU -gt 1) ]]
then
if [ -f /etc/sonic/database_global.json ]; then
cp /etc/sonic/database_global.json $REDIS_DIR/sonic-db/database_global.json
cp /etc/sonic/database_global.json $VALKEY_DIR/sonic-db/database_global.json
else
j2 /usr/share/sonic/templates/database_global.json.j2 > $REDIS_DIR/sonic-db/database_global.json
j2 /usr/share/sonic/templates/database_global.json.j2 > $VALKEY_DIR/sonic-db/database_global.json
fi
fi
# delete chassisdb config to generate supervisord config
Expand All @@ -116,9 +116,9 @@ fi
rm $db_cfg_file_tmp

# copy dump.rdb file to each instance for restoration
DUMPFILE=/var/lib/redis/dump.rdb
redis_inst_list=`/usr/bin/python3 -c "from swsscommon import swsscommon; print(' '.join(swsscommon.SonicDBConfig.getInstanceList().keys()))"`
for inst in $redis_inst_list
DUMPFILE=/var/lib/valkey/dump.rdb
valkey_inst_list=`/usr/bin/python3 -c "from swsscommon import swsscommon; print(' '.join(swsscommon.SonicDBConfig.getInstanceList().keys()))"`
for inst in $valkey_inst_list
do
mkdir -p /var/lib/$inst
if [[ -f $DUMPFILE ]]; then
Expand All @@ -129,12 +129,12 @@ do
else
echo -n > /var/lib/$inst/dump.rdb
fi
# the Redis process is operating under the 'redis' user in supervisord and make redis user own /var/lib/$inst inside db container.
chown -R redis:redis /var/lib/$inst
# the Valkey process is operating under the 'valkey' user in supervisord and make valkey user own /var/lib/$inst inside db container.
chown -R valkey:valkey /var/lib/$inst
done

chown -R redis:redis $REDIS_DIR
REDIS_BMP_DIR="/var/lib/redis_bmp"
chown -R redis:redis $REDIS_BMP_DIR
chown -R valkey:valkey $VALKEY_DIR
VALKEY_BMP_DIR="/var/lib/valkey_bmp"
chown -R valkey:valkey $VALKEY_BMP_DIR

exec /usr/local/bin/supervisord
2 changes: 1 addition & 1 deletion dockers/docker-database/flush_unused_database
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ for instname, v in instlists.items():

connector.flushdb()
except RuntimeError:
syslog.syslog(syslog.LOG_INFO,"flushdb:Redis Unix Socket connection error for path {} and dbaname {}".format(instsocket, dbname))
syslog.syslog(syslog.LOG_INFO,"flushdb:Valkey Unix Socket connection error for path {} and dbaname {}".format(instsocket, dbname))
14 changes: 7 additions & 7 deletions dockers/docker-database/supervisord.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ stderr_syslog=true
dependent_startup=true

{% if INSTANCES %}
{% for redis_inst, redis_items in INSTANCES.items() %}
{%- if redis_inst != 'remote_redis' %}
[program:{{ redis_inst }}]
{% if redis_items['hostname'] != '127.0.0.1' %}
{% for valkey_inst, valkey_items in INSTANCES.items() %}
{%- if valkey_inst != 'remote_valkey' %}
[program:{{ valkey_inst }}]
{% if valkey_items['hostname'] != '127.0.0.1' %}
{%- set ADDITIONAL_OPTS = '--protected-mode no' %}
{%- if redis_inst != 'redis_chassis' %}
{%- if valkey_inst != 'valkey_chassis' %}
{%- set LOOPBACK_IP = '127.0.0.1' -%}
{%- endif -%}
{%- else -%}
{%- set LOOPBACK_IP = '' -%}
{%- set ADDITIONAL_OPTS = '' %}
{%- endif -%}
command=/bin/bash -c "{ [[ -s /var/lib/{{ redis_inst }}/dump.rdb ]] || rm -f /var/lib/{{ redis_inst }}/dump.rdb; } && mkdir -p /var/lib/{{ redis_inst }} && exec /usr/bin/redis-server /etc/redis/redis.conf --bind {{ LOOPBACK_IP }} {{ redis_items['hostname'] }} --port {{ redis_items['port'] }} --unixsocket {{ redis_items['unix_socket_path'] }} --pidfile /var/run/redis/{{ redis_inst }}.pid --dir /var/lib/{{ redis_inst }} {{ ADDITIONAL_OPTS }}"
command=/bin/bash -c "{ [[ -s /var/lib/{{ valkey_inst }}/dump.rdb ]] || rm -f /var/lib/{{ valkey_inst }}/dump.rdb; } && mkdir -p /var/lib/{{ valkey_inst }} && exec /usr/bin/valkey-server /etc/valkey/valkey.conf --bind {{ LOOPBACK_IP }} {{ valkey_items['hostname'] }} --port {{ valkey_items['port'] }} --unixsocket {{ valkey_items['unix_socket_path'] }} --pidfile /var/run/valkey/{{ valkey_inst }}.pid --dir /var/lib/{{ valkey_inst }} {{ ADDITIONAL_OPTS }}"
priority=2
user=redis
user=valkey
autostart=true
autorestart=false
stdout_logfile=NONE
Expand Down
2 changes: 1 addition & 1 deletion platform/p4/docker-sonic-p4/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ RUN sed -ri 's/^(save .*$)/# \1/g;
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
' /etc/valkey/valkey.conf

COPY ["port_config.ini", "/port_config.ini"]
COPY ["start.sh", "orchagent.sh", "config_bm.sh", "/usr/bin/"]
Expand Down
6 changes: 3 additions & 3 deletions platform/vs/docker-sonic-vs/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ RUN apt-get install -y net-tools \
libasan6 \
{%- endif %}
dbus \
redis-server \
valkey-server \
# For libkrb5-dev
comerr-dev \
libgssrpc4 \
Expand Down Expand Up @@ -120,11 +120,11 @@ RUN sed -ri 's/^# save ""$/save ""/g; \
s/^logfile .*$/logfile ""/; \
s/^# syslog-enabled no$/syslog-enabled no/; \
s/^# unixsocket/unixsocket/; \
s/redis-server.sock/redis.sock/g; \
s/valkey-server.sock/valkey.sock/g; \
s/^client-output-buffer-limit pubsub [0-9]+mb [0-9]+mb [0-9]+/client-output-buffer-limit pubsub 0 0 0/; \
s/^notify-keyspace-events ""$/notify-keyspace-events AKE/; \
s/^databases [0-9]+$/databases 100/ \
' /etc/redis/redis.conf
' /etc/valkey/valkey.conf

COPY ["50-default.conf", "/etc/rsyslog.d/"]
COPY ["start.sh", "orchagent.sh", "files/update_chassisdb_config", "/usr/bin/"]
Expand Down
Loading