Skip to content

Commit

Permalink
[config] Check golden config exist early if flag is set (sonic-net#3169)
Browse files Browse the repository at this point in the history
### What I did
Fix  sonic-net#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
  • Loading branch information
wen587 committed Feb 22, 2024
1 parent 1c094d3 commit 6e4130d
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 @@ -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...")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6e4130d

Please sign in to comment.