Skip to content

Commit

Permalink
Improve config error handling on version_info (#1760)
Browse files Browse the repository at this point in the history
#### What I did
`get_sonic_version_info()` may return `None` if `/etc/sonic/sonic_version.yml` does not exist. Previously the `config` exit without any useful information.

Some `config` subcommands do not depend on sonic version info, we should allow them to run.
  • Loading branch information
qiluo-msft authored Aug 18, 2021
1 parent 5002745 commit a99d56d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,8 +950,12 @@ def config(ctx):

try:
version_info = device_info.get_sonic_version_info()
asic_type = version_info['asic_type']
except (KeyError, TypeError):
if version_info:
asic_type = version_info['asic_type']
else:
asic_type = None
except (KeyError, TypeError) as e:
print("Caught an exception: " + str(e))
raise click.Abort()

# Load database config files
Expand Down

0 comments on commit a99d56d

Please sign in to comment.