Skip to content

Commit 911f41e

Browse files
nazariigmssonicbld
authored andcommitted
[sonic-cfggen]: Optimize template rendering and database access. (#17740)
#### Why I did it * Improved switch init time ### How I did it * Replaced: `sonic-cfggen` -> `sonic-db-cli` * Aggregated template list for `sonic-cfggen` #### How to verify it 1. Run `warm-reboot`
1 parent e2ae581 commit 911f41e

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
@@ -63,8 +63,9 @@ if [[ $DATABASE_TYPE == "chassisdb" ]]; then
6363
echo "Init docker-database-chassis..."
6464
update_chassisdb_config -j $db_cfg_file_tmp -k -p $chassis_db_port
6565
# generate all redis server supervisord configuration file
66-
sonic-cfggen -j $db_cfg_file_tmp -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf
67-
sonic-cfggen -j $db_cfg_file_tmp -t /usr/share/sonic/templates/critical_processes.j2 > /etc/supervisor/critical_processes
66+
sonic-cfggen -j $db_cfg_file_tmp \
67+
-t /usr/share/sonic/templates/supervisord.conf.j2,/etc/supervisor/conf.d/supervisord.conf \
68+
-t /usr/share/sonic/templates/critical_processes.j2,/etc/supervisor/critical_processes
6869
rm $db_cfg_file_tmp
6970
exec /usr/local/bin/supervisord
7071
exit 0
@@ -81,8 +82,9 @@ then
8182
fi
8283
# delete chassisdb config to generate supervisord config
8384
update_chassisdb_config -j $db_cfg_file_tmp -d
84-
sonic-cfggen -j $db_cfg_file_tmp -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf
85-
sonic-cfggen -j $db_cfg_file_tmp -t /usr/share/sonic/templates/critical_processes.j2 > /etc/supervisor/critical_processes
85+
sonic-cfggen -j $db_cfg_file_tmp \
86+
-t /usr/share/sonic/templates/supervisord.conf.j2,/etc/supervisor/conf.d/supervisord.conf \
87+
-t /usr/share/sonic/templates/critical_processes.j2,/etc/supervisor/critical_processes
8688

8789
if [[ "$start_chassis_db" != "1" ]] && [[ -z "$chassis_db_address" ]]; then
8890
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)