Skip to content

[database]: Update the DPU database service configuration #17562

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

Merged
merged 8 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
17 changes: 13 additions & 4 deletions dockers/docker-database/database_config.json.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% set include_remote_db = (REMOTE_DB_IP is defined and REMOTE_DB_PORT is defined) %}
{
"INSTANCES": {
"redis":{
Expand All @@ -15,6 +16,14 @@
"unix_socket_path": "/var/run/redis-chassis/redis_chassis.sock",
"persistence_for_warm_boot" : "yes"
}
{% if include_remote_db %}
,"remote_redis":{
"hostname" : "{{REMOTE_DB_IP}}",
"port" : {{REMOTE_DB_PORT}},
"unix_socket_path": ""
"persistence_for_warm_boot" : "yes"
}
{% endif %}
},
"DATABASES" : {
"APPL_DB" : {
Expand Down Expand Up @@ -102,23 +111,23 @@
"DPU_APPL_DB" : {
"id" : 15,
"separator": ":",
"instance" : "redis",
"instance" : {% if include_remote_db%} "remote_redis" {% else %} "redis" {% endif %},
Copy link
Contributor

Choose a reason for hiding this comment

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

@Pterosaur which design doc are you following? I am not sure, if the DPU_

will be hosted on the NPU side or DPU side?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add the design doc to the description and that has been reviewed by community.

Copy link
Collaborator

@qiluo-msft qiluo-msft Apr 9, 2024

Choose a reason for hiding this comment

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

%

Do you want to add a blank before %? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

"format": "proto"
},
"DPU_APPL_STATE_DB" : {
"id" : 16,
"separator": "|",
"instance" : "redis"
"instance" : {% if include_remote_db%} "remote_redis" {% else %} "redis" {% endif %}
},
"DPU_STATE_DB" : {
"id" : 17,
"separator": "|",
"instance" : "redis"
"instance" : {% if include_remote_db%} "remote_redis" {% else %} "redis" {% endif %}
},
"DPU_COUNTERS_DB" : {
"id" : 18,
"separator": ":",
"instance" : "redis"
"instance" : {% if include_remote_db%} "remote_redis" {% else %} "redis" {% endif %}
}
{% endif %}
},
Expand Down
13 changes: 13 additions & 0 deletions dockers/docker-database/docker-database-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ if [[ $DATABASE_TYPE == "dpudb" ]]; then
redis_port=`expr 6381 + $DPU_ID`
fi

# TODO: Check the current platform is DPU
midplane_ip=$(ip -4 -o addr | grep -v "169.254.200.254" | grep "169.254.200" | awk '{print $4}' | cut -d'/' -f1 | head -1 )
if [[ $midplane_ip != "" ]]
then
export DATABASE_TYPE="dpudb"
export REMOTE_DB_IP="169.254.200.254"
IFS=. read -r a b c d <<< "169.254.200.1"
midplane_base_ip_num=$((a * 256 ** 3 + b * 256 ** 2 + c * 256 + d))
# Determine the DB PORT from midplane IP
IFS=. read -r a b c d <<< $midplane_ip
midplane_ip_num=$((a * 256 ** 3 + b * 256 ** 2 + c * 256 + d))
export REMOTE_DB_PORT=$((6381 + $midplane_ip_num - $midplane_base_ip_num))
Copy link
Contributor

@prgeor prgeor Dec 19, 2023

Choose a reason for hiding this comment

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

@Pterosaur you can get the ip from the "eth0-midplane" interface. Use the last digit (1 for DPU1, 2 for DPU 2, and so on)

REMOTE_DB_PORT = 6380 + <last digit of the IP>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion, done.

fi

REDIS_DIR=/var/run/redis$NAMESPACE_ID
mkdir -p $REDIS_DIR/sonic-db
Expand Down