From df15c9ad0fc74ae78232592e0d5dff3a1736326e Mon Sep 17 00:00:00 2001 From: malletvapid23 Date: Mon, 8 Feb 2021 11:55:42 -0800 Subject: [PATCH] Fix: initialize SonicDBConfig differently for single or multi_asic (#1409) **- What I did** Fixes https://github.com/Azure/sonic-buildimage/issues/6708 This bug is exposed by https://github.com/Azure/sonic-utilities/pull/1392. Previously the `config` command will call `SonicDBConfig.load_sonic_global_db_config()` even on a single ASIC platform, and it will silently failed. After exposed, it will fail with error syslog message: ``` admin@sonic:~$ sudo config save Existing files will be overwritten, continue? [y/N]: ^CAborted! Feb 8 03:23:48.729434 sonic ERR sniffer: :- initializeGlobalConfig: Sonic database config global file doesn't exist at /var/run/redis/sonic-db/database_global.json ``` **- How to verify it** Tested on DUT --- config/main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/config/main.py b/config/main.py index 2e8c139..5adf913 100644 --- a/config/main.py +++ b/config/main.py @@ -931,7 +931,11 @@ def config(ctx): platform.add_command(mlnx.mlnx) # Load the global config file database_global.json once. - SonicDBConfig.load_sonic_global_db_config() + num_asic = multi_asic.get_num_asics() + if num_asic > 1: + SonicDBConfig.load_sonic_global_db_config() + else: + SonicDBConfig.initialize() if os.geteuid() != 0: exit("Root privileges are required for this operation")