Skip to content

Commit

Permalink
add debug logs for database_global bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarashinvd committed May 24, 2023
1 parent a9cd1a6 commit 6e7dbae
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/sonic-config-engine/sonic-cfggen
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ from sonic_py_common.multi_asic import get_asic_id_from_name, get_asic_device_id
from sonic_py_common import device_info
from swsscommon.swsscommon import ConfigDBConnector, SonicDBConfig, ConfigDBPipeConnector

try:
from sonic_py_common.logger import Logger
except ImportError as e:
raise ImportError (str(e) + "- required module not found")

# Global logger class instance
logger = Logger()


PY3x = sys.version_info >= (3, 0)

Expand Down Expand Up @@ -140,8 +148,10 @@ def ip_network(value):
def load_namespace_config(asic_name):
if not SonicDBConfig.isInit():
if is_multi_asic():
logger.log_notice("calling load_sonic_global_db_config, is_multi_asic: {}".format(is_multi_asic()))
SonicDBConfig.load_sonic_global_db_config(namespace=asic_name)
else:
logger.log_notice("calling load_sonic_db_config, is_multi_asic: {}".format(is_multi_asic()))
SonicDBConfig.load_sonic_db_config()

class FormatConverter:
Expand Down
12 changes: 12 additions & 0 deletions src/sonic-py-common/sonic_py_common/multi_asic.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
from .device_info import get_asic_conf_file_path
from .device_info import is_supervisor, is_chassis

try:
from sonic_py_common.logger import Logger
except ImportError as e:
raise ImportError (str(e) + "- required module not found")

# Global logger class instance
logger = Logger()

ASIC_NAME_PREFIX = 'asic'
NAMESPACE_PATH_GLOB = '/run/netns/*'
ASIC_CONF_FILENAME = 'asic.conf'
Expand Down Expand Up @@ -89,15 +97,18 @@ def get_num_asics():
asic_conf_file_path = get_asic_conf_file_path()

if asic_conf_file_path is None:
logger.log_notice("asic_conf_file_path is None, returning 1")
return 1

logger.log_notice("asic_conf_file_path: {}".format(asic_conf_file_path))
with open(asic_conf_file_path) as asic_conf_file:
for line in asic_conf_file:
tokens = line.split('=')
if len(tokens) < 2:
continue
if tokens[0].lower() == 'num_asic':
num_asics = tokens[1].strip()
logger.log_notice("returning num asic: {}".format(num_asics))
return int(num_asics)


Expand All @@ -110,6 +121,7 @@ def is_multi_asic():
"""
num_asics = get_num_asics()

logger.log_notice("is_multi_asic returning: {}".format(num_asics > 1))
return (num_asics > 1)


Expand Down

0 comments on commit 6e7dbae

Please sign in to comment.