-
Notifications
You must be signed in to change notification settings - Fork 669
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
Validate config_db json file before config reload #3063
Conversation
Remove STR casting and if check for more than 1 config_db json files
@abdosi: Can you please help review this? |
@mihirpat1, Can you please help review this? |
command = [SONIC_CFGGEN_PATH, '-j', file] | ||
clicommon.run_command(command) | ||
for inst in range(0, num_cfg_file-1): | ||
file = "/etc/sonic/config_db{}.json".format(inst) |
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.
@AnoopKamath is this tested on multi-asic platform?
file = "/etc/sonic/config_db{}.json".format(inst) | ||
if os.path.exists(file): | ||
command = [SONIC_CFGGEN_PATH, '-j', file] | ||
clicommon.run_command(command) |
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.
@AnoopKamath will this raise exception on failure?
@qiluo-msft could you review? |
@@ -1515,6 +1515,18 @@ def reload(db, filename, yes, load_sysinfo, no_service_restart, force, file_form | |||
click.echo("Input {} config file(s) separated by comma for multiple files ".format(num_cfg_file)) | |||
return | |||
|
|||
#Validate config_db.json file |
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.
@@ -1515,6 +1515,18 @@ def reload(db, filename, yes, load_sysinfo, no_service_restart, force, file_form | |||
click.echo("Input {} config file(s) separated by comma for multiple files ".format(num_cfg_file)) | |||
return | |||
|
|||
#Validate config_db.json file | |||
if file_format == 'config_db': | |||
file = DEFAULT_CONFIG_DB_FILE |
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.
Please add positive and negative testcases. |
We do have json validator: https://github.com/sonic-net/sonic-utilities/blob/master/config/main.py#L1559
|
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.
check comment
What I did
Check config_db json file before stopping the services. If there is an error, DB wont be able to connect to any services
How I did it
Run the SONIC_CFGGEN_PATH to all the one or more config_db.json file. If there is any error, it will come out of config reload loop before stopping all the services.
How to verify it
Create an error in config_db.json and we should see any error before all the services go down.
Previous command output (if the output of a command-line utility has changed)
Suppose there is an extra "," issue in one of the config_db.json file and when we issue 'config reload' there is no validation for config_db.json file. Only when DB services will restart and encounter issue it will flag it but it has brought all the services down. Now none of the services will start and most of the commands wont run and system will hang when we issue config reload or reboot.
New command output (if the output of a command-line utility has changed)