Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[202012] Use unix socket path in ConfigDBConnector for some components #10436

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sonic-host-services/scripts/hostcfgd
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ class HostConfigDaemon:
def __init__(self):
# Just a sanity check to verify if the CONFIG_DB has been initialized
# before moving forward
self.config_db = ConfigDBConnector()
self.config_db = ConfigDBConnector(use_unix_socket_path=True)
self.config_db.connect(wait_for_init=True, retry_on=True)
self.dbconn = DBConnector(CFG_DB, 0)
self.selector = Select()
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-py-common/sonic_py_common/device_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

def get_localhost_info(field):
try:
config_db = ConfigDBConnector()
config_db = ConfigDBConnector(use_unix_socket_path=True)
config_db.connect()

metadata = config_db.get_table('DEVICE_METADATA')
Expand Down
12 changes: 6 additions & 6 deletions src/sonic-py-common/sonic_py_common/multi_asic.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
PORT_ROLE = 'role'


def connect_config_db_for_ns(namespace=DEFAULT_NAMESPACE):
def connect_config_db_for_ns(namespace=DEFAULT_NAMESPACE, use_unix_socket_path=False):
"""
The function connects to the config DB for a given namespace and
returns the handle
Expand All @@ -40,12 +40,12 @@ def connect_config_db_for_ns(namespace=DEFAULT_NAMESPACE):
handle to the config_db for a namespace
"""
SonicDBConfig.load_sonic_global_db_config()
config_db = ConfigDBConnector(namespace=namespace)
config_db = ConfigDBConnector(namespace=namespace, use_unix_socket_path=use_unix_socket_path)
config_db.connect()
return config_db


def connect_to_all_dbs_for_ns(namespace=DEFAULT_NAMESPACE):
def connect_to_all_dbs_for_ns(namespace=DEFAULT_NAMESPACE, use_unix_socket_path=False):
"""
The function connects to the DBs for a given namespace and
returns the handle
Expand All @@ -59,7 +59,7 @@ def connect_to_all_dbs_for_ns(namespace=DEFAULT_NAMESPACE):
handle to all the dbs for a namespaces
"""
SonicDBConfig.load_sonic_global_db_config()
db = SonicV2Connector(namespace=namespace)
db = SonicV2Connector(namespace=namespace, use_unix_socket_path=use_unix_socket_path)
for db_id in db.get_db_list():
db.connect(db_id)
return db
Expand Down Expand Up @@ -227,7 +227,7 @@ def get_all_namespaces():
if is_multi_asic():
for asic in range(num_asics):
namespace = "{}{}".format(ASIC_NAME_PREFIX, asic)
config_db = connect_config_db_for_ns(namespace)
config_db = connect_config_db_for_ns(namespace, use_unix_socket_path=True)

metadata = config_db.get_table('DEVICE_METADATA')
if metadata['localhost']['sub_role'] == FRONTEND_ASIC_SUB_ROLE:
Expand Down Expand Up @@ -296,7 +296,7 @@ def get_port_entry_for_asic(port, namespace):

def get_port_table_for_asic(namespace):

config_db = connect_config_db_for_ns(namespace)
config_db = connect_config_db_for_ns(namespace, use_unix_socket_path=True)
ports = config_db.get_table(PORT_CFG_DB_TABLE)
return ports

Expand Down