-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[dpu]: Add DPU database service #17161
Changes from 6 commits
8bc0e30
9d7e6aa
307b8c8
7aa84c9
d8ea2bd
b309999
d26601f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,10 @@ | |
"INSTANCES": { | ||
"redis":{ | ||
"hostname" : "{{HOST_IP}}", | ||
"port" : 6379, | ||
"unix_socket_path" : "/var/run/redis{{NAMESPACE_ID}}/redis.sock", | ||
"persistence_for_warm_boot" : "yes" | ||
"port" : {{REDIS_PORT}}, | ||
"unix_socket_path" : "/var/run/redis{{DEV}}/redis.sock", | ||
"persistence_for_warm_boot" : "yes", | ||
"database_type": "{{DATABASE_TYPE}}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we add a check to add the field "database_type" if DATABASE_TYPE is defined? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
}, | ||
"redis_chassis":{ | ||
"hostname" : "redis_chassis.server", | ||
|
@@ -94,6 +95,30 @@ | |
"separator": ":", | ||
"instance" : "redis" | ||
} | ||
{% if DATABASE_TYPE is defined and DATABASE_TYPE == "dpudb" %} | ||
, | ||
"DPU_APPL_DB" : { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe i missed some update, so just checking - have we decided to use DPU_APPL_DB or DASH_APPL_DB and etc. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I want to introduce new databases like, |
||
"id" : 15, | ||
"separator": ":", | ||
"instance" : "redis", | ||
"format": "proto" | ||
}, | ||
"DPU_APPL_STATE_DB" : { | ||
"id" : 16, | ||
"separator": "|", | ||
"instance" : "redis" | ||
}, | ||
"DPU_STATE_DB" : { | ||
"id" : 17, | ||
"separator": "|", | ||
"instance" : "redis" | ||
}, | ||
"DPU_COUNTERS_DB" : { | ||
"id" : 18, | ||
"separator": ":", | ||
"instance" : "redis" | ||
} | ||
{% endif %} | ||
}, | ||
"VERSION" : "1.0" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
{% set namespace_cnt = NAMESPACE_COUNT|int %} | ||
{% if NUM_DPU is defined %} | ||
{% set dpu_cnt = NUM_DPU | int %} | ||
{% else %} | ||
{% set dpu_cnt = 0 %} | ||
{% endif %} | ||
{ | ||
"INCLUDES" : [ | ||
{ | ||
"include" : "../../redis/sonic-db/database_config.json" | ||
}, | ||
|
||
{% if namespace_cnt > 1 %} | ||
{% for ns in range(namespace_cnt) %} | ||
{ | ||
|
@@ -15,7 +21,22 @@ | |
}, | ||
{% endif %} | ||
{% endfor %} | ||
{% endif %} | ||
|
||
{% if dpu_cnt > 0 %} | ||
{% for dpu in range(dpu_cnt) %} | ||
{ | ||
"database_type" : "dpudb", | ||
"include" : "../../redisdpu{{dpu}}/sonic-db/database_config.json" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: i wonder if we could use "redis-dpu{{dpu}}" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and we can do it in another change, since this change is already approved. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not easy. Because the database folder consists of the prefix "redis" and suffix "$DEV" without the dash "-". This convention has been used in the multi-ASIC scenario. |
||
{% if dpu == dpu_cnt-1 %} | ||
} | ||
{% else %} | ||
}, | ||
{% endif %} | ||
{% endfor %} | ||
{% endif %} | ||
|
||
], | ||
"VERSION" : "1.0" | ||
} | ||
{% endif %} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,14 +17,26 @@ then | |
host_ip=127.0.0.1 | ||
fi | ||
|
||
redis_port=6379 | ||
|
||
if [[ $DATABASE_TYPE == "dpudb" ]]; then | ||
host_ip="169.254.200.254" | ||
if ! ip -4 -o addr | awk '{print $4}' | grep $host_ip; then | ||
host_ip=127.0.0.1 | ||
fi | ||
DPU_ID=`echo $DEV | tr -dc '0-9'` | ||
redis_port=`expr 6381 + $DPU_ID` | ||
fi | ||
|
||
|
||
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 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 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 | ||
|
@@ -59,7 +71,7 @@ if [[ $DATABASE_TYPE == "chassisdb" ]]; then | |
fi | ||
|
||
# copy/generate the database_global.json file if this is global database service in multi asic platform. | ||
if [[ $NAMESPACE_ID == "" ]] && [[ $NAMESPACE_COUNT -gt 1 ]] | ||
if [[ $DATABASE_TYPE == "" ]] && [[ $NAMESPACE_COUNT -gt 1 || $NUM_DPU -gt 1 ]] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this check $NAMESPACE_ID == "" changed here to use $DATABASE_TYPE ? This check originally meant we are working in the host namespace where namespace is "" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the DPU scenario, all dpu databases are running in the host namespace which means the namespace_id is also empty to the dpu database instance. So, I use database_type == "" to identify the host db instance. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From what I understand in case of dpu we set the DATABASE_TYPE as below, and for all other cases like single_asic/multi-asic DATABASE_TYPE will be "" The earlier check below was applicable only to global db which is in host namespace in case of multi-asic/single asic
So now with this change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right, I will fix it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix it in PR: #17221 Please help to check it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Taking a look. |
||
then | ||
if [ -f /etc/sonic/database_global.json ]; then | ||
cp /etc/sonic/database_global.json $REDIS_DIR/sonic-db/database_global.json | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,9 @@ | |
CHASSIS_INFO_MODEL_FIELD = 'model' | ||
CHASSIS_INFO_REV_FIELD = 'revision' | ||
|
||
# DPU constants | ||
DPU_NAME_PREFIX = "dpu" | ||
|
||
# Cacheable Objects | ||
sonic_ver_info = {} | ||
hw_info_dict = {} | ||
|
@@ -841,3 +844,24 @@ def is_frontend_port_present_in_host(): | |
if not namespace_id: | ||
return False | ||
return True | ||
|
||
|
||
def get_num_dpus(): | ||
num_dpus = 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's add todo here. we should use platform api to get the dpu number instead of rely on the platform env config. @prgeor . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
platform_env_conf_file_path = get_platform_env_conf_file_path() | ||
|
||
# platform_env.conf file not present for platform | ||
if platform_env_conf_file_path is None: | ||
return num_dpus | ||
|
||
# Else open the file check for keyword - num_dpu - | ||
with open(platform_env_conf_file_path) as platform_env_conf_file: | ||
for line in platform_env_conf_file: | ||
tokens = line.split('=') | ||
if len(tokens) < 2: | ||
continue | ||
if tokens[0].lower() == 'num_dpu': | ||
num_dpus = tokens[1].strip() | ||
break | ||
return int(num_dpus) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this change expected? do we need 100 databases or it is changed for testing but later forget to remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default value of databases is 16 which isn't enough for new databases of DPU.