From 6e4130d8e2f95094f8f294206a0578b0babb354e Mon Sep 17 00:00:00 2001 From: jingwenxie Date: Fri, 23 Feb 2024 05:57:53 +0800 Subject: [PATCH] [config] Check golden config exist early if flag is set (#3169) ### What I did Fix https://github.com/sonic-net/sonic-utilities/issues/3164 Check Golden Config earlier before service is down. #### How I did it Move the check at the begining #### How to verify it Unit test --- config/main.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/config/main.py b/config/main.py index b039c56929..f2113f255f 100644 --- a/config/main.py +++ b/config/main.py @@ -1707,6 +1707,15 @@ def load_minigraph(db, no_service_restart, traffic_shift_away, override_config, argv_str = ' '.join(['config', *sys.argv[1:]]) log.log_notice(f"'load_minigraph' executing with command: {argv_str}") + # check if golden_config exists if override flag is set + if override_config: + if golden_config_path is None: + golden_config_path = DEFAULT_GOLDEN_CONFIG_DB_FILE + if not os.path.isfile(golden_config_path): + click.secho("Cannot find '{}'!".format(golden_config_path), + fg='magenta') + raise click.Abort() + #Stop services before config push if not no_service_restart: log.log_notice("'load_minigraph' stopping services...") @@ -1778,12 +1787,6 @@ def load_minigraph(db, no_service_restart, traffic_shift_away, override_config, # Load golden_config_db.json if override_config: - if golden_config_path is None: - golden_config_path = DEFAULT_GOLDEN_CONFIG_DB_FILE - if not os.path.isfile(golden_config_path): - click.secho("Cannot find '{}'!".format(golden_config_path), - fg='magenta') - raise click.Abort() override_config_by(golden_config_path) # Invoke platform script if available before starting the services