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 Aug 27, 2024
1 parent d52dc8e commit f657d5f
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 @@ -1709,6 +1709,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 @@ -1780,12 +1789,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 f657d5f

Please sign in to comment.