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] Remove hardcoded config and migrate config from minigraph #2887

Merged
merged 8 commits into from
Jun 29, 2023

Conversation

vaibhavhd
Copy link
Contributor

@vaibhavhd vaibhavhd commented Jun 27, 2023

What I did

Microsoft ADO: 18217044

This PR is follow up to an old PR: #2515

This PR addresses two issues:

  1. Not migrating RESTAPI, TELEMETRY, DEVICE_METADATA entries if they are not supported in target image's minigraph.py.
  2. Not migrating these entries if minigraph.xml file is missing.
  3. Not maintaining the config for these tables in two different places. Currently db migrator has its own constants, and minigraph.py maintains its own.

How I did it

This change removes hardcoding config in migrator code, and migrating the config for RESTAPI, TELEMETRY, DEVICE_METADATA from minigraph generator.

How to verify it

Tested on a physical device.

This change works w/ another change to fix config-setup, database dependency sonic-net/sonic-buildimage#14933

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)

@@ -527,6 +535,9 @@ def migrate_vxlan_config(self):

def migrate_restapi(self):
# RESTAPI - add missing key
if not self.minigraph_data or 'RESTAPI' not in self.minigraph_data:
return
RESTAPI = self.minigraph_data['RESTAPI']
Copy link
Contributor

@qiluo-msft qiluo-msft Jun 28, 2023

Choose a reason for hiding this comment

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

RESTAPI

RESTAPI -> restapi_data. It's not a constant anymore. Many occurences in this file. #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.

Updated now

# load config data from minigraph to get the default/hardcoded values from minigraph.py
# this is to avoid duplicating the hardcoded these values in db_migrator
self.minigraph_data = None
if os.path.isfile(MINIGRAPH_FILE):
Copy link
Contributor

@qiluo-msft qiluo-msft Jun 28, 2023

Choose a reason for hiding this comment

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

isfile

Could you add a testcase for missing MINIGRAPH_FILE? It would be even better if you can add a testcase for L2 switch mode #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.

ack

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a new testcase for missing minigraph. We can discuss what other fields are expected/unexpected in L2 switch's case and add a test for that in future PR. What do you suggest?

Copy link
Contributor

Choose a reason for hiding this comment

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

Add a test for L2 switch in future is okay.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As per offline discussion: from unit test level the test for missing minigraph and absence of default entries is sufficient. L2 switch config and functionality needs to be tested separately as part of sonic-mgmt test. Raised a test gap for this: sonic-net/sonic-mgmt#8777

# this is to avoid duplicating the hardcoded these values in db_migrator
self.minigraph_data = None
if os.path.isfile(MINIGRAPH_FILE):
self.minigraph_data = parse_xml(MINIGRAPH_FILE)
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 against parse_xml throwing error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Added now.

yxieca
yxieca previously approved these changes Jun 29, 2023
dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'config_db', 'cross_branch_upgrade_without_mg_2_0_2_expected.json')
expected_db = Db()

expected_db
Copy link
Contributor

@qiluo-msft qiluo-msft Jun 29, 2023

Choose a reason for hiding this comment

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

expected_db

remove this line? #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.

Removed here, and also in the old testcase.

@vaibhavhd vaibhavhd merged commit 7bc08c2 into sonic-net:master Jun 29, 2023
4 checks passed
@vaibhavhd vaibhavhd deleted the route-mode-separated branch June 29, 2023 21:11
@liuh-80 liuh-80 added the Approved for 202012 Branch Approved for 202012 Branch label Jul 6, 2023
yxieca pushed a commit that referenced this pull request Jul 7, 2023
…ph (#2887)

Microsoft ADO: 18217044

This PR is follow up to an old PR: #2515

This PR addresses two issues:

Not migrating RESTAPI, TELEMETRY, DEVICE_METADATA entries if they are not supported in target image's minigraph.py.
Not migrating these entries if minigraph.xml file is missing.
Not maintaining the config for these tables in two different places. Currently db migrator has its own constants, and minigraph.py maintains its own.
How I did it
This change removes hardcoding config in migrator code, and migrating the config for RESTAPI, TELEMETRY, DEVICE_METADATA from minigraph generator.

How to verify it
Tested on a physical device.
dgsudharsan added a commit to dgsudharsan/sonic-buildimage that referenced this pull request Jul 11, 2023
Update sonic-utilities submodule pointer to include the following:
* ff380e04 [hash]: Implement GH frontend ([sonic-net#2580](sonic-net/sonic-utilities#2580))
* 61bad064 [db_migrator] Set correct CURRENT_VERSION, extend UT ([sonic-net#2895](sonic-net/sonic-utilities#2895))
* 6b8ee47c [CLI][Show][BGP] Show BGP Change for no neighbor scenario ([sonic-net#2885](sonic-net/sonic-utilities#2885))
* 73d8d633 [doc] Update Command-Reference.md, change show bgp peer command to show bfd peer ([sonic-net#2750](sonic-net/sonic-utilities#2750))
* 7bc08c28 [db_migrator] Remove hardcoded config and migrate config from minigraph ([sonic-net#2887](sonic-net/sonic-utilities#2887))
* b1aa9426 [generate_dump]: Enhance show techsupport for Marvell platform ([sonic-net#2676](sonic-net/sonic-utilities#2676))
* 316b14c0 Add support for secure upgrade ([sonic-net#2698](sonic-net/sonic-utilities#2698))
* dc2945bc [dns] Implement config and show commands for static DNS. ([sonic-net#2737](sonic-net/sonic-utilities#2737))
* 8414a709 [chassis][multi asic] change acl_loader to use tcp socket for db communication ([sonic-net#2525](sonic-net/sonic-utilities#2525))
* 0b629ba1 Revert [chassis][voq] Clear fabric counters queue/port (2789) ([sonic-net#2882](sonic-net/sonic-utilities#2882))
* 3ba8241a [db_migtrator] Add migration of FLEX_COUNTER_DELAY_STATUS during 1911->master upgrade + fast-reboot. Add UT. ([sonic-net#2839](sonic-net/sonic-utilities#2839))
* fceef2ed [chassis][voq] Clear fabric counters queue/port ([sonic-net#2789](sonic-net/sonic-utilities#2789))

Signed-off-by: dgsudharsan <sudharsand@nvidia.com>
liat-grozovik pushed a commit to sonic-net/sonic-buildimage that referenced this pull request Jul 11, 2023
Update sonic-utilities submodule pointer to include the following:
* ff380e04 [hash]: Implement GH frontend ([#2580](sonic-net/sonic-utilities#2580))
* 61bad064 [db_migrator] Set correct CURRENT_VERSION, extend UT ([#2895](sonic-net/sonic-utilities#2895))
* 6b8ee47c [CLI][Show][BGP] Show BGP Change for no neighbor scenario ([#2885](sonic-net/sonic-utilities#2885))
* 73d8d633 [doc] Update Command-Reference.md, change show bgp peer command to show bfd peer ([#2750](sonic-net/sonic-utilities#2750))
* 7bc08c28 [db_migrator] Remove hardcoded config and migrate config from minigraph ([#2887](sonic-net/sonic-utilities#2887))
* b1aa9426 [generate_dump]: Enhance show techsupport for Marvell platform ([#2676](sonic-net/sonic-utilities#2676))
* 316b14c0 Add support for secure upgrade ([#2698](sonic-net/sonic-utilities#2698))
* dc2945bc [dns] Implement config and show commands for static DNS. ([#2737](sonic-net/sonic-utilities#2737))
* 8414a709 [chassis][multi asic] change acl_loader to use tcp socket for db communication ([#2525](sonic-net/sonic-utilities#2525))
* 0b629ba1 Revert [chassis][voq] Clear fabric counters queue/port (2789) ([#2882](sonic-net/sonic-utilities#2882))
* 3ba8241a [db_migtrator] Add migration of FLEX_COUNTER_DELAY_STATUS during 1911->master upgrade + fast-reboot. Add UT. ([#2839](sonic-net/sonic-utilities#2839))
* fceef2ed [chassis][voq] Clear fabric counters queue/port ([#2789](sonic-net/sonic-utilities#2789))

Signed-off-by: dgsudharsan <sudharsand@nvidia.com>
StormLiangMS pushed a commit that referenced this pull request Jul 19, 2023
…ph (#2887)

Microsoft ADO: 18217044

This PR is follow up to an old PR: #2515

This PR addresses two issues:

Not migrating RESTAPI, TELEMETRY, DEVICE_METADATA entries if they are not supported in target image's minigraph.py.
Not migrating these entries if minigraph.xml file is missing.
Not maintaining the config for these tables in two different places. Currently db migrator has its own constants, and minigraph.py maintains its own.
How I did it
This change removes hardcoding config in migrator code, and migrating the config for RESTAPI, TELEMETRY, DEVICE_METADATA from minigraph generator.

How to verify it
Tested on a physical device.
@qiluo-msft
Copy link
Contributor

This commit could not be cleanly cherry-pick to 202012. Please raise another PR on that branch.

vaibhavhd added a commit to vaibhavhd/sonic-utilities that referenced this pull request Jul 21, 2023
…ph (sonic-net#2887)

Microsoft ADO: 18217044

This PR is follow up to an old PR: sonic-net#2515

This PR addresses two issues:

Not migrating RESTAPI, TELEMETRY, DEVICE_METADATA entries if they are not supported in target image's minigraph.py.
Not migrating these entries if minigraph.xml file is missing.
Not maintaining the config for these tables in two different places. Currently db migrator has its own constants, and minigraph.py maintains its own.
How I did it
This change removes hardcoding config in migrator code, and migrating the config for RESTAPI, TELEMETRY, DEVICE_METADATA from minigraph generator.

How to verify it
Tested on a physical device.
@StormLiangMS
Copy link
Contributor

caused UT failure in internal branch sync, @vaibhavhd

{
'values_changed': {
"root['certs']['ca_crt']": {
'new_value': '/etc/sonic/credentials/restapica.crt',
'old_value': '/et...name'
]": {'new_value': 'client.restapi.sonic', 'old_value': 'client.restapi.sonic.gbl,vnetds.prod.int.azure-int.net'}}}

@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 26, 2023
@liuh-80
Copy link
Contributor

liuh-80 commented Jul 26, 2023

Cherry-pick to 202012 PR: #2924

qiluo-msft pushed a commit that referenced this pull request Jul 26, 2023
…ph (#2887) (#2924)

Microsoft ADO: 18217044

This PR is follow up to an old PR: #2515

This PR addresses two issues:

Not migrating RESTAPI, TELEMETRY, DEVICE_METADATA entries if they are not supported in target image's minigraph.py.
Not migrating these entries if minigraph.xml file is missing.
Not maintaining the config for these tables in two different places. Currently db migrator has its own constants, and minigraph.py maintains its own.
How I did it
This change removes hardcoding config in migrator code, and migrating the config for RESTAPI, TELEMETRY, DEVICE_METADATA from minigraph generator.

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
…ph (sonic-net#2887)

Microsoft ADO: 18217044

This PR is follow up to an old PR: sonic-net#2515

This PR addresses two issues:

Not migrating RESTAPI, TELEMETRY, DEVICE_METADATA entries if they are not supported in target image's minigraph.py.
Not migrating these entries if minigraph.xml file is missing.
Not maintaining the config for these tables in two different places. Currently db migrator has its own constants, and minigraph.py maintains its own.
How I did it
This change removes hardcoding config in migrator code, and migrating the config for RESTAPI, TELEMETRY, DEVICE_METADATA from minigraph generator.

How to verify it
Tested on a physical device.
yxieca pushed a commit that referenced this pull request Aug 29, 2023
…ph (#2887)

Microsoft ADO: 18217044

This PR is follow up to an old PR: #2515

This PR addresses two issues:

Not migrating RESTAPI, TELEMETRY, DEVICE_METADATA entries if they are not supported in target image's minigraph.py.
Not migrating these entries if minigraph.xml file is missing.
Not maintaining the config for these tables in two different places. Currently db migrator has its own constants, and minigraph.py maintains its own.
How I did it
This change removes hardcoding config in migrator code, and migrating the config for RESTAPI, TELEMETRY, DEVICE_METADATA from minigraph generator.

How to verify it
Tested on a physical device.
sonic-otn pushed a commit to sonic-otn/sonic-buildimage that referenced this pull request Sep 20, 2023
Update sonic-utilities submodule pointer to include the following:
* ff380e04 [hash]: Implement GH frontend ([sonic-net#2580](sonic-net/sonic-utilities#2580))
* 61bad064 [db_migrator] Set correct CURRENT_VERSION, extend UT ([sonic-net#2895](sonic-net/sonic-utilities#2895))
* 6b8ee47c [CLI][Show][BGP] Show BGP Change for no neighbor scenario ([sonic-net#2885](sonic-net/sonic-utilities#2885))
* 73d8d633 [doc] Update Command-Reference.md, change show bgp peer command to show bfd peer ([sonic-net#2750](sonic-net/sonic-utilities#2750))
* 7bc08c28 [db_migrator] Remove hardcoded config and migrate config from minigraph ([sonic-net#2887](sonic-net/sonic-utilities#2887))
* b1aa9426 [generate_dump]: Enhance show techsupport for Marvell platform ([sonic-net#2676](sonic-net/sonic-utilities#2676))
* 316b14c0 Add support for secure upgrade ([sonic-net#2698](sonic-net/sonic-utilities#2698))
* dc2945bc [dns] Implement config and show commands for static DNS. ([sonic-net#2737](sonic-net/sonic-utilities#2737))
* 8414a709 [chassis][multi asic] change acl_loader to use tcp socket for db communication ([sonic-net#2525](sonic-net/sonic-utilities#2525))
* 0b629ba1 Revert [chassis][voq] Clear fabric counters queue/port (2789) ([sonic-net#2882](sonic-net/sonic-utilities#2882))
* 3ba8241a [db_migtrator] Add migration of FLEX_COUNTER_DELAY_STATUS during 1911->master upgrade + fast-reboot. Add UT. ([sonic-net#2839](sonic-net/sonic-utilities#2839))
* fceef2ed [chassis][voq] Clear fabric counters queue/port ([sonic-net#2789](sonic-net/sonic-utilities#2789))

Signed-off-by: dgsudharsan <sudharsand@nvidia.com>
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.

5 participants