Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[db-migrator] Fix hwsku match for 6100 and add errors when hwsku is None #2821

Merged
merged 2 commits into from
May 30, 2023

Conversation

vaibhavhd
Copy link
Contributor

@vaibhavhd vaibhavhd commented May 3, 2023

What I did

MSFT ADO: 17972494

Fix errors in db migration when hwsku is not detected.
This PR is adds a better-error-handling fix for the issue that is fixed by: sonic-net/sonic-buildimage#14933

May  2 20:35:04 sonic database.sh[649]: Creating new database container
May  2 20:35:04 sonic database.sh[663]: 99e8edba01ed0c7581f0d61dd2fa78374fa4f23e636a957004dd03a6f68eea86
May  2 20:35:04 sonic root: Starting database service...
May  2 20:35:06 sonic database.sh[690]: database
May  2 20:35:10 sonic database.sh[926]: True

May  2 20:35:10 sonic database.sh[928]:   File "/usr/local/bin/db_migrator.py", line 714, in common_migration_ops
May  2 20:35:10 sonic database.sh[928]:   File "/usr/local/bin/db_migrator.py", line 741, in migrate
May  2 20:35:10 sonic database.sh[928]:   File "/usr/local/bin/db_migrator.py", line 782, in main
May  2 20:35:10 sonic database.sh[928]: Traceback (most recent call last):
May  2 20:35:10 sonic database.sh[928]: TypeError: argument of type 'NoneType' is not iterable
May  2 20:35:10 sonic database.sh[928]: argument of type 'NoneType' is not iterable
May  2 20:35:10 sonic database.sh[928]: optional arguments:
May  2 20:35:10 sonic database.sh[928]: usage: db_migrator.py [-h] [-o operation migrate, set_version, get_version]
May  2 20:35:10 sonic db_migrator: :- operator(): DB '{APPL_DB}' is empty with pattern 'COPP_TABLE:*'!
May  2 20:35:10 sonic db_migrator: :- operator(): DB '{APPL_DB}' is empty with pattern 'INTF_TABLE:*'!
May  2 20:35:10 sonic db_migrator: :- operator(): Key 'BUFFER_MAX_PARAM_TABLE|global' field 'mmu_size' unavailable in database 'STATE_DB'
May  2 20:35:10 sonic db_migrator: :- operator(): Key 'WARM_RESTART_ENABLE_TABLE|system' field 'enable' unavailable in database 'STATE_DB'
May  2 20:35:10 sonic db_migrator: Caught exception: argument of type 'NoneType' is not iterable

May  2 20:35:11 sonic config-setup[935]: Copying SONiC configuration minigraph.xml ...
May  2 20:35:11 sonic config-setup[935]: Reloading minigraph...
May  2 20:35:11 sonic config-setup[935]: Use minigraph.xml from old system...

May  2 20:35:11 sonic root: Started database service...

How I did it

Convert hwsku's type to str before checking substring.
Add error logs when hwsku and asic type information is not obtained.

How to verify it

Tested on a physical device

Previous command output (if the output of a command-line utility has changed)

New command output (if the output of a command-line utility has changed)

@vaibhavhd vaibhavhd changed the title Fix hwsku match for 6100 and add errors when hwsku is None [db-migrator] Fix hwsku match for 6100 and add errors when hwsku is None May 3, 2023
@vaibhavhd vaibhavhd requested review from yxieca and kellyyeh May 3, 2023 19:34
kellyyeh
kellyyeh previously approved these changes May 3, 2023
@@ -989,7 +992,7 @@ def common_migration_ops(self):
# removed together with calling to migrate_copp_table function.
if self.asic_type != "mellanox":
self.migrate_copp_table()
if self.asic_type == "broadcom" and 'Force10-S6100' in self.hwsku:
if self.asic_type == "broadcom" and 'Force10-S6100' in str(self.hwsku):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to protect the possibility that self.hwsku is none?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If self.hwsku is None then str(None) will convert None to a string and in check will still work.

Alternative is (as we want to ensure self.hwsku is always a string:
if self.asic_type == "broadcom" and type(self.hwsku) = str and 'Force10-S6100' in str(self.hwsku):

@tjchadaga
Copy link
Contributor

Fixes sonic-net/sonic-buildimage#12083

@lguohan
Copy link
Contributor

lguohan commented May 13, 2023

can you add ado?

@yxieca yxieca merged commit b5c1032 into sonic-net:master May 30, 2023
@qiluo-msft
Copy link
Contributor

@vaibhavhd This commit could not be cleanly cherry-picked to 202012. Please submit another PR.

yxieca pushed a commit that referenced this pull request Jun 2, 2023
…one (#2821)

* Fix hwsku match for 6100 and add errors when hwsku is None

* Asic type fix
@liuh-80
Copy link
Contributor

liuh-80 commented Jun 28, 2023

@vaibhavhd , please create manually cherry-pick PR to 202012, if this PR not required for 202012, please remove 'Request for 202012 branch' label

@liuh-80 liuh-80 added the Cherry Pick PR created_202012 Label for a manually cherry-pick PR created for 202012 cherry-pick conflict PR. label Jul 7, 2023
vaibhavhd added a commit that referenced this pull request Jul 24, 2023
…sku is None (#2896)

Cherry pick of #2821

MSFT ADO: 17972494

Fix errors in db migration when hwsku is not detected.
This PR is adds a better-error-handling fix for the issue that is fixed by: sonic-net/sonic-buildimage#14933

May  2 20:35:04 sonic database.sh[649]: Creating new database container
May  2 20:35:04 sonic database.sh[663]: 99e8edba01ed0c7581f0d61dd2fa78374fa4f23e636a957004dd03a6f68eea86
May  2 20:35:04 sonic root: Starting database service...
May  2 20:35:06 sonic database.sh[690]: database
May  2 20:35:10 sonic database.sh[926]: True

May  2 20:35:10 sonic database.sh[928]:   File "/usr/local/bin/db_migrator.py", line 714, in common_migration_ops
May  2 20:35:10 sonic database.sh[928]:   File "/usr/local/bin/db_migrator.py", line 741, in migrate
May  2 20:35:10 sonic database.sh[928]:   File "/usr/local/bin/db_migrator.py", line 782, in main
May  2 20:35:10 sonic database.sh[928]: Traceback (most recent call last):
May  2 20:35:10 sonic database.sh[928]: TypeError: argument of type 'NoneType' is not iterable
May  2 20:35:10 sonic database.sh[928]: argument of type 'NoneType' is not iterable
May  2 20:35:10 sonic database.sh[928]: optional arguments:
May  2 20:35:10 sonic database.sh[928]: usage: db_migrator.py [-h] [-o operation migrate, set_version, get_version]
May  2 20:35:10 sonic db_migrator: :- operator(): DB '{APPL_DB}' is empty with pattern 'COPP_TABLE:*'!
May  2 20:35:10 sonic db_migrator: :- operator(): DB '{APPL_DB}' is empty with pattern 'INTF_TABLE:*'!
May  2 20:35:10 sonic db_migrator: :- operator(): Key 'BUFFER_MAX_PARAM_TABLE|global' field 'mmu_size' unavailable in database 'STATE_DB'
May  2 20:35:10 sonic db_migrator: :- operator(): Key 'WARM_RESTART_ENABLE_TABLE|system' field 'enable' unavailable in database 'STATE_DB'
May  2 20:35:10 sonic db_migrator: Caught exception: argument of type 'NoneType' is not iterable

May  2 20:35:11 sonic config-setup[935]: Copying SONiC configuration minigraph.xml ...
May  2 20:35:11 sonic config-setup[935]: Reloading minigraph...
May  2 20:35:11 sonic config-setup[935]: Use minigraph.xml from old system...

May  2 20:35:11 sonic root: Started database service...
How I did it
Convert hwsku's type to str before checking substring.
Add error logs when hwsku and asic type information is not obtained.

How to verify it
Tested on a physical device
pdhruv-marvell pushed a commit to pdhruv-marvell/sonic-utilities that referenced this pull request Aug 23, 2023
…one (sonic-net#2821)

* Fix hwsku match for 6100 and add errors when hwsku is None

* Asic type fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants