From e32b51b228dade55d602ff1d01a51d61dc2520f2 Mon Sep 17 00:00:00 2001 From: Nazarii Hnydyn Date: Thu, 14 Dec 2023 18:50:25 +0200 Subject: [PATCH] [sonic-cfggen]: Optimize template rendering and database access. Signed-off-by: Nazarii Hnydyn --- dockers/docker-database/docker-database-init.sh | 10 ++++++---- dockers/docker-orchagent/docker-init.j2 | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/dockers/docker-database/docker-database-init.sh b/dockers/docker-database/docker-database-init.sh index 9fe5ae242245..f6f8522bb944 100755 --- a/dockers/docker-database/docker-database-init.sh +++ b/dockers/docker-database/docker-database-init.sh @@ -63,8 +63,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 @@ -81,8 +82,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 diff --git a/dockers/docker-orchagent/docker-init.j2 b/dockers/docker-orchagent/docker-init.j2 index 1e8574de153b..41dbe27285f1 100755 --- a/dockers/docker-orchagent/docker-init.j2 +++ b/dockers/docker-orchagent/docker-init.j2 @@ -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.