Skip to content

Commit a99d56d

Browse files
authored
Improve config error handling on version_info (#1760)
#### 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.
1 parent 5002745 commit a99d56d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

config/main.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -950,8 +950,12 @@ def config(ctx):
950950

951951
try:
952952
version_info = device_info.get_sonic_version_info()
953-
asic_type = version_info['asic_type']
954-
except (KeyError, TypeError):
953+
if version_info:
954+
asic_type = version_info['asic_type']
955+
else:
956+
asic_type = None
957+
except (KeyError, TypeError) as e:
958+
print("Caught an exception: " + str(e))
955959
raise click.Abort()
956960

957961
# Load database config files

0 commit comments

Comments
 (0)