-
Notifications
You must be signed in to change notification settings - Fork 656
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
Fix db_migrate.py show error and back trace while loading configuration on Linecard #3257
Changes from all commits
2469d6f
5c92d04
1c0c074
0cebcab
e4b5c9e
b4e03b9
c812b74
bbc2496
1652c65
e17e4a2
ce14d3e
0154882
40c2f21
1f41eb3
4b13a57
3930718
d28cffe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,10 +8,9 @@ | |
import re | ||
|
||
from sonic_py_common import device_info, logger | ||
from swsscommon.swsscommon import SonicV2Connector, ConfigDBConnector | ||
from swsscommon.swsscommon import SonicV2Connector, ConfigDBConnector, SonicDBConfig | ||
from minigraph import parse_xml | ||
from utilities_common.helper import update_config | ||
from utilities_common.general import load_db_config | ||
|
||
INIT_CFG_FILE = '/etc/sonic/init_cfg.json' | ||
MINIGRAPH_FILE = '/etc/sonic/minigraph.xml' | ||
|
@@ -1277,7 +1276,14 @@ def main(): | |
socket_path = args.socket | ||
namespace = args.namespace | ||
|
||
load_db_config() | ||
# Can't load global config base on the result of is_multi_asic(), because on multi-asic device, when db_migrate.py | ||
# run on the local database, ASIC instance will have not created the /var/run/redis0/sonic-db/database-config.json | ||
if args.namespace is not None: | ||
if not SonicDBConfig.isGlobalInit(): | ||
SonicDBConfig.initializeGlobalConfig() | ||
else: | ||
if not SonicDBConfig.isInit(): | ||
SonicDBConfig.initialize() | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel it is more like a timing issue as you pointed out, Can we call db_migrator, after /var/run/redis0/sonic-db/database-config.json is created ? Here, https://github.com/sonic-net/sonic-swss-common/blob/7db6ccf5fb427d4832d6c54ab1f485ddd87b6697/common/dbconnector.h#L107 -- it doesn't make a difference if we pass/don't pass the namespace parameter to load_sonic_global_db_config() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I search sonic code but not found any code use the '-n' parameter of db_migrator.py to pass the namespace parameter. For load_sonic_global_db_config(namespace=args.namespace), I think it's better keep the parameter to keep the compatibility, incase we change the code of load_sonic_global_db_config in future. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @liuh-80 @judyjoseph all instance database@.service have dependency "Requires=database.service |
||
if socket_path: | ||
dbmgtr = DBMigrator(namespace, socket=socket_path) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a general issue? If yes, do we need to fix them all and destroy this function? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a general issue, according to the code of this script and Judy's comments, this script seems designed to be run before ASIC instance database0 and database1 generate database-config.json.
For other code using load_db_config this issue should not happen.