Skip to content

Commit a3b5ea9

Browse files
authored
[sonic-cfggen]: Optimize template rendering and database access. (sonic-net#17650)
Signed-off-by: Nazarii Hnydyn [email protected] Why I did it Improved switch init time Work item tracking N/A How I did it Replaced: sonic-cfggen -> sonic-db-cli Aggregated template list for sonic-cfggen How to verify it Run warm-reboot
1 parent 44bc291 commit a3b5ea9

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

dockers/docker-database/docker-database-init.sh

+6-4
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ if [[ $DATABASE_TYPE == "chassisdb" ]]; then
5151
echo "Init docker-database-chassis..."
5252
update_chassisdb_config -j $db_cfg_file_tmp -k -p $chassis_db_port
5353
# generate all redis server supervisord configuration file
54-
sonic-cfggen -j $db_cfg_file_tmp -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf
55-
sonic-cfggen -j $db_cfg_file_tmp -t /usr/share/sonic/templates/critical_processes.j2 > /etc/supervisor/critical_processes
54+
sonic-cfggen -j $db_cfg_file_tmp \
55+
-t /usr/share/sonic/templates/supervisord.conf.j2,/etc/supervisor/conf.d/supervisord.conf \
56+
-t /usr/share/sonic/templates/critical_processes.j2,/etc/supervisor/critical_processes
5657
rm $db_cfg_file_tmp
5758
exec /usr/local/bin/supervisord
5859
exit 0
@@ -69,8 +70,9 @@ then
6970
fi
7071
# delete chassisdb config to generate supervisord config
7172
update_chassisdb_config -j $db_cfg_file_tmp -d
72-
sonic-cfggen -j $db_cfg_file_tmp -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf
73-
sonic-cfggen -j $db_cfg_file_tmp -t /usr/share/sonic/templates/critical_processes.j2 > /etc/supervisor/critical_processes
73+
sonic-cfggen -j $db_cfg_file_tmp \
74+
-t /usr/share/sonic/templates/supervisord.conf.j2,/etc/supervisor/conf.d/supervisord.conf \
75+
-t /usr/share/sonic/templates/critical_processes.j2,/etc/supervisor/critical_processes
7476

7577
if [[ "$start_chassis_db" != "1" ]] && [[ -z "$chassis_db_address" ]]; then
7678
cp $db_cfg_file_tmp $db_cfg_file

dockers/docker-orchagent/docker-init.j2

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ CFGGEN_PARAMS=" \
2323
-t /usr/share/sonic/templates/wait_for_link.sh.j2,/usr/bin/wait_for_link.sh \
2424
"
2525
VLAN=$(sonic-cfggen $CFGGEN_PARAMS)
26-
SUBTYPE=$(sonic-cfggen -d -v "DEVICE_METADATA['localhost']['subtype']")
27-
SWITCH_TYPE=${SWITCH_TYPE:-`sonic-cfggen -d -v "DEVICE_METADATA['localhost']['switch_type']"`}
26+
SUBTYPE=$(sonic-db-cli -s CONFIG_DB HGET 'DEVICE_METADATA|localhost' 'subtype')
27+
SWITCH_TYPE=${SWITCH_TYPE:-`sonic-db-cli -s CONFIG_DB HGET 'DEVICE_METADATA|localhost' 'switch_type'`}
2828
chmod +x /usr/bin/wait_for_link.sh
2929

3030
# Executed platform specific initialization tasks.

0 commit comments

Comments
 (0)