Skip to content

Commit

Permalink
[config] Check golden config exist early if flag is set (#3169) (#3504)
Browse files Browse the repository at this point in the history
### What I did
Fix  #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

Co-authored-by: jingwenxie <jingwenxie@microsoft.com>
  • Loading branch information
mssonicbld and wen587 committed Aug 28, 2024
1 parent 3bdaca0 commit f72699f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1746,6 +1746,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...")
Expand Down Expand Up @@ -1817,12 +1826,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
Expand Down

0 comments on commit f72699f

Please sign in to comment.