Skip to content

Commit

Permalink
Add new redis database instance for BMP_STATE_DB. (#19016)
Browse files Browse the repository at this point in the history
#### Why I did it
Add new redis database instance for BMP_STATE_DB. since bmp data set will be a bit large which we don't want block existing state_db operation.

#### How I did it
Changed database config and will use it into other bmp relevant PR.
  • Loading branch information
FengPan-Frank authored Oct 24, 2024
1 parent b3e379c commit 06c469e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
15 changes: 13 additions & 2 deletions dockers/docker-database/database_config.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@
"unix_socket_path": "",
"persistence_for_warm_boot" : "yes"
}
{% endif %}
{% endif %},
"redis_bmp":{
"hostname" : "{{HOST_IP}}",
"port" : {{BMP_DB_PORT}},
"unix_socket_path" : "/var/run/redis{{DEV}}/redis_bmp.sock",
"persistence_for_warm_boot" : "yes"
}
},
"DATABASES" : {
"APPL_DB" : {
Expand Down Expand Up @@ -129,7 +135,12 @@
"separator": ":",
"instance" : {% if include_remote_db %} "remote_redis" {% else %} "redis" {% endif %}
}
{% endif %}
{% endif %},
"BMP_STATE_DB" : {
"id" : 20,
"separator": "|",
"instance" : "redis_bmp"
}
},
"VERSION" : "1.0"
}
6 changes: 5 additions & 1 deletion dockers/docker-database/docker-database-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,16 @@ then
fi
fi

export BMP_DB_PORT=6400

REDIS_DIR=/var/run/redis$NAMESPACE_ID
mkdir -p $REDIS_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
else
HOST_IP=$host_ip REDIS_PORT=$redis_port DATABASE_TYPE=$DATABASE_TYPE 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 > $REDIS_DIR/sonic-db/database_config.json
fi

# on VoQ system, we only publish redis_chassis instance and CHASSIS_APP_DB when
Expand Down Expand Up @@ -130,5 +132,7 @@ rm -rf /etc/localtime
ln -sf /usr/share/zoneinfo/$TZ /etc/localtime

chown -R redis:redis $REDIS_DIR
REDIS_BMP_DIR="/var/lib/redis_bmp"
chown -R redis:redis $REDIS_BMP_DIR

exec /usr/local/bin/supervisord
3 changes: 3 additions & 0 deletions files/build_templates/docker_image_ctl.j2
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ function preStartAction()
# Create an emtpy file and overwrite any RDB if already there
echo -n > /tmp/dump.rdb
docker cp /tmp/dump.rdb database$DEV:/var/lib/redis/
docker cp /tmp/dump.rdb database$DEV:/var/lib/redis_bmp/
fi
fi
{%- elif docker_container_name == "pde" %}
Expand Down Expand Up @@ -296,7 +297,9 @@ function postStartAction()
fi
REDIS_SOCK="/var/run/redis-chassis/redis_chassis.sock"
fi
REDIS_BMP_SOCK="/var/run/redis/redis_bmp.sock"
chgrp -f redis $REDIS_SOCK && chmod -f 0760 $REDIS_SOCK
chgrp -f redis $REDIS_BMP_SOCK && chmod -f 0760 $REDIS_BMP_SOCK
{%- elif docker_container_name == "swss" %}
# Wait until swss container state is Running
until [[ ($(docker inspect -f {{"'{{.State.Running}}'"}} swss$DEV) == "true") ]]; do
Expand Down

0 comments on commit 06c469e

Please sign in to comment.