Skip to content

Commit

Permalink
[config-chassisdb] use cached variables
Browse files Browse the repository at this point in the history
No cache:

```
root@arc-switch1004:/home/admin# time bash -x /usr/bin/config-chassisdb
+ config_chassis_db
+ startdb_file=/etc/sonic/chassisdb.conf
+ '[' '!' -e /etc/sonic/chassisdb.conf ']'
++ sonic-cfggen -H -v DEVICE_METADATA.localhost.platform
+ platform=x86_64-mlnx_msn2700-r0
+ chassis_config=/usr/share/sonic/device/x86_64-mlnx_msn2700-r0/chassisdb.conf
+ '[' '!' -e /usr/share/sonic/device/x86_64-mlnx_msn2700-r0/chassisdb.conf ']'
+ echo 'no chassisdb.conf found, bypass config-chassisdb service'
no chassisdb.conf found, bypass config-chassisdb service
+ exit 0

real    0m0.512s
user    0m0.429s
sys     0m0.058s
```

With cache:

```
root@arc-switch1004:/home/admin# time bash -x /usr/bin/config-chassisdb
+ '[' -f /etc/sonic/sonic-environment ']'
+ . /etc/sonic/sonic-environment
++ SONIC_VERSION=202305_RC.32-da745b71d_Internal
++ PLATFORM=x86_64-mlnx_msn2700-r0
++ HWSKU=Mellanox-SN2700-D48C8
++ DEVICE_TYPE=ToRRouter
++ ASIC_TYPE=mellanox
+ config_chassis_db
+ startdb_file=/etc/sonic/chassisdb.conf
+ '[' '!' -e /etc/sonic/chassisdb.conf ']'
+ platform=x86_64-mlnx_msn2700-r0
+ chassis_config=/usr/share/sonic/device/x86_64-mlnx_msn2700-r0/chassisdb.conf
+ '[' '!' -e /usr/share/sonic/device/x86_64-mlnx_msn2700-r0/chassisdb.conf ']'
+ echo 'no chassisdb.conf found, bypass config-chassisdb service'
no chassisdb.conf found, bypass config-chassisdb service
+ exit 0

real    0m0.017s
user    0m0.005s
sys     0m0.008s
```

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
  • Loading branch information
stepanblyschak committed Nov 21, 2023
1 parent 1bf2012 commit 7a20049
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion files/image_config/config-chassisdb/config-chassisdb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
config_chassis_db() {
startdb_file="/etc/sonic/chassisdb.conf"
[ ! -e $startdb_file ] || rm $startdb_file
platform=$(sonic-cfggen -H -v DEVICE_METADATA.localhost.platform)
platform=${PLATFORM:-`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`}
# database-chassis services will start when $chassis_config file exists
chassis_config="/usr/share/sonic/device/$platform/chassisdb.conf"
if [ ! -e $chassis_config ]; then
Expand All @@ -54,6 +54,9 @@ config_chassis_db() {
fi
}

# read SONiC immutable variables
[ -f /etc/sonic/sonic-environment ] && . /etc/sonic/sonic-environment

config_chassis_db

exit 0

0 comments on commit 7a20049

Please sign in to comment.