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

Bind ASIC database instances to midplane IPs #20803

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions files/build_templates/docker_image_ctl.j2
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ function waitForAllInstanceDatabaseConfigJsonFilesReady()
function postStartAction()
{
{%- if docker_container_name == "database" %}
midplane_ip=""
CHASSISDB_CONF="/usr/share/sonic/device/$PLATFORM/chassisdb.conf"
[ -f $CHASSISDB_CONF ] && source $CHASSISDB_CONF
if [[ "$DEV" && $DATABASE_TYPE != "dpudb" ]]; then
Expand Down Expand Up @@ -198,6 +199,11 @@ function postStartAction()
ip netns exec "$NET_NS" ip addr add $slot_ip_address/$slot_subnet_mask dev eth1
ip netns exec "$NET_NS" ip link set dev eth1 up

# Don't run for supervisor
if [[ "${slot_id}" != "${supervisor_slot_id}" ]]; then
midplane_ip=$slot_ip_address
fi

# Allow localnet routing on the new interfaces if midplane is using a
# subnet in the 127/8 range.
if [[ "${midplane_subnet#127}" != "$midplane_subnet" ]]; then
Expand Down Expand Up @@ -300,6 +306,14 @@ function postStartAction()
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

if [[ $DEV && $midplane_ip ]]; then
IFS=_ read ip port < <(jq -r '.INSTANCES | [.redis.hostname, .redis.port] | join("_")' /var/run/redis$DEV/sonic-db/database_config.json)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead doing a bind here using redis-cli. Is it possible to update the hostIP to midplane-ip database_config.json for chassis?

Copy link
Contributor Author

@vivekverma-arista vivekverma-arista Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have explored that possibility as well.

The issue is that midplane IPs take a little longer to get assigned when the switch is coming up whereas the docker network IPs are already available by the time this script starts running: https://github.com/sonic-net/sonic-buildimage/blob/master/dockers/docker-database/docker-database-init.sh#L5-L10

If we want to update database_config.json and bind redis instances to midplane IPs alone, the instantiation of redis database instances has to be delayed till the midplane IPs are assigned.

Delaying something critical as database which also happens to be SPOF for the entire system can have consequences and it's an unknown territory. We don't know all the consequences it can have.

bound_ips=$(redis-cli --raw -h $ip -p $port config get bind | sed -n '2,2 p')
redis-cli -h $ip -p $port config set bind "$bound_ips $midplane_ip"
redis-cli -h $ip -p $port config rewrite
fi

{%- elif docker_container_name == "swss" %}
# Wait until swss container state is Running
until [[ ($(docker inspect -f {{"'{{.State.Running}}'"}} swss$DEV) == "true") ]]; do
Expand Down
Loading