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

Migrate GNMI table #3053

Merged
merged 7 commits into from
Jan 29, 2024
Merged

Migrate GNMI table #3053

merged 7 commits into from
Jan 29, 2024

Conversation

ganglyu
Copy link
Contributor

@ganglyu ganglyu commented Nov 27, 2023

What I did

We will use GNMI container to replace TELEMETRY container in public repo.
GNMI is using GNMI table for configuration, so we need to migrate configuration in CONFIG_DB.
For L2 mode, there's no GNMI configuration in minigraph, and there's no TELEMETRY table in CONFIG_DB, so we will not generate GNMI table.

How I did it

If there's no minigraph and golden config, copy GNMI configuration from TELEMETRY table.
If there're minigraph and golden config, copy GNMI configuration from minigraph or golden config.

How to verify it

Run db migrator unit test, test with minigraph and test without minigraph.

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)

@qiluo-msft qiluo-msft requested a review from vaibhavhd November 29, 2023 02:25
def migrate_gnmi(self):
# GNMI - add missing key
if not self.minigraph_data or 'GNMI' not in self.minigraph_data:
# If there's no GNMI in minigraph, copy configuration from CONFIG_DB TELEMETRY table
Copy link
Contributor

@qiluo-msft qiluo-msft Nov 30, 2023

Choose a reason for hiding this comment

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

If there's no GNMI in minigraph, copy configuration from CONFIG_DB TELEMETRY table

Could you double check if this works with L2 switch mode? https://github.com/sonic-net/SONiC/wiki/L2-Switch-mode #Closed

Copy link
Contributor

Choose a reason for hiding this comment

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

We previously has a bug that mistakenly generating config for telemetry in L2 mode.

Copy link
Contributor Author

@ganglyu ganglyu Dec 1, 2023

Choose a reason for hiding this comment

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

sonic-net/sonic-mgmt#8777
L2 switch mode is a test gap, and this issue is still open.
When there's no GNMI table in minigraph, db migrator will copy from CONFIG_DB TELEMETRY table to CONFIG_DB GNMI table.
When there's GNMI table in minigraph, db migrator will copy from minigraph GNMI table to CONFIG_DB GNMI table.
For L2 switch mode, minigraph is empty and CONFIG_DB does not have TELEMETRY table, and then db migrator will not generate config for GNMI.

@qiluo-msft qiluo-msft requested review from yxieca and removed request for yxieca December 11, 2023 23:52
@@ -1090,7 +1109,8 @@ def version_4_0_4(self):
Version 4_0_4.
"""
log.log_info('Handling version_4_0_4')

# Updating GNMI table
self.migrate_gnmi()
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding to an existing version is not safe. What if this operation was executed on a device running an older sonic image which already has database version reached 4.0.4?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

# GNMI - add missing key
if not self.minigraph_data or 'GNMI' not in self.minigraph_data:
# If there's no GNMI in minigraph, copy configuration from CONFIG_DB TELEMETRY table
gnmi = self.configDB.get_entry('TELEMETRY', 'gnmi')
Copy link
Contributor

@qiluo-msft qiluo-msft Dec 12, 2023

Choose a reason for hiding this comment

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

get_entry

Will this line still work if TELEMETRY table is completely missing in ConfigDB? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, if TELEMETRY table is missing, db_migrator will not generate GNMI table.

@ganglyu ganglyu requested review from qiluo-msft and yxieca December 26, 2023 08:36
gnmi_data = self.config_src_data['GNMI']
log.log_notice('Migrate GNMI configuration')
if 'gnmi' in gnmi_data:
self.configDB.set_entry("GNMI", "gnmi", gnmi_data.get('gnmi'))
Copy link
Contributor

@qiluo-msft qiluo-msft Dec 27, 2023

Choose a reason for hiding this comment

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

self.configDB

There are upgrade/downgrade use cases. If self.configDB['GNMI'] already exists, you should not modify, right? #Closed

Copy link
Contributor Author

@ganglyu ganglyu Dec 27, 2023

Choose a reason for hiding this comment

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

Fixed, now I check GNMI table at first

@ganglyu ganglyu requested a review from qiluo-msft December 28, 2023 01:44
@@ -6,6 +6,6 @@
"state": "enabled"
},
"VERSIONS|DATABASE": {
"VERSION": "version_4_0_4"
"VERSION": "version_202405_01"
Copy link
Contributor

@yxieca yxieca Jan 2, 2024

Choose a reason for hiding this comment

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

You should not need to make this change. Is there a reason for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's no version_4_0_4 in db_migrator.py, does it make sense to use it in test?

Copy link
Contributor

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

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

LGTM, please check with other reviewers.

@ganglyu ganglyu requested a review from yxieca January 8, 2024 08:06
@yxieca yxieca merged commit 3d45c0c into sonic-net:master Jan 29, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants