Skip to content

Commit

Permalink
[sonic-cfggen]: Optimize template rendering and database access. (#17650
Browse files Browse the repository at this point in the history
)

Signed-off-by: Nazarii Hnydyn nazariig@nvidia.com

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
  • Loading branch information
nazariig authored Jan 10, 2024
1 parent 44bc291 commit a3b5ea9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions dockers/docker-database/docker-database-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ if [[ $DATABASE_TYPE == "chassisdb" ]]; then
echo "Init docker-database-chassis..."
update_chassisdb_config -j $db_cfg_file_tmp -k -p $chassis_db_port
# generate all redis server supervisord configuration file
sonic-cfggen -j $db_cfg_file_tmp -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf
sonic-cfggen -j $db_cfg_file_tmp -t /usr/share/sonic/templates/critical_processes.j2 > /etc/supervisor/critical_processes
sonic-cfggen -j $db_cfg_file_tmp \
-t /usr/share/sonic/templates/supervisord.conf.j2,/etc/supervisor/conf.d/supervisord.conf \
-t /usr/share/sonic/templates/critical_processes.j2,/etc/supervisor/critical_processes
rm $db_cfg_file_tmp
exec /usr/local/bin/supervisord
exit 0
Expand All @@ -69,8 +70,9 @@ then
fi
# delete chassisdb config to generate supervisord config
update_chassisdb_config -j $db_cfg_file_tmp -d
sonic-cfggen -j $db_cfg_file_tmp -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf
sonic-cfggen -j $db_cfg_file_tmp -t /usr/share/sonic/templates/critical_processes.j2 > /etc/supervisor/critical_processes
sonic-cfggen -j $db_cfg_file_tmp \
-t /usr/share/sonic/templates/supervisord.conf.j2,/etc/supervisor/conf.d/supervisord.conf \
-t /usr/share/sonic/templates/critical_processes.j2,/etc/supervisor/critical_processes

if [[ "$start_chassis_db" != "1" ]] && [[ -z "$chassis_db_address" ]]; then
cp $db_cfg_file_tmp $db_cfg_file
Expand Down
4 changes: 2 additions & 2 deletions dockers/docker-orchagent/docker-init.j2
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ CFGGEN_PARAMS=" \
-t /usr/share/sonic/templates/wait_for_link.sh.j2,/usr/bin/wait_for_link.sh \
"
VLAN=$(sonic-cfggen $CFGGEN_PARAMS)
SUBTYPE=$(sonic-cfggen -d -v "DEVICE_METADATA['localhost']['subtype']")
SWITCH_TYPE=${SWITCH_TYPE:-`sonic-cfggen -d -v "DEVICE_METADATA['localhost']['switch_type']"`}
SUBTYPE=$(sonic-db-cli -s CONFIG_DB HGET 'DEVICE_METADATA|localhost' 'subtype')
SWITCH_TYPE=${SWITCH_TYPE:-`sonic-db-cli -s CONFIG_DB HGET 'DEVICE_METADATA|localhost' 'switch_type'`}
chmod +x /usr/bin/wait_for_link.sh

# Executed platform specific initialization tasks.
Expand Down

0 comments on commit a3b5ea9

Please sign in to comment.