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

Support multiple database for DPU #174

Closed
wants to merge 3 commits into from

Conversation

ganglyu
Copy link
Contributor

@ganglyu ganglyu commented Dec 9, 2023

Why I did it

sonic-net/sonic-buildimage#17161
We have updated database configuration to support multiple databases for smartswitch.
And then we need to update sonic-gnmi to support new database configuration and new GNMI path for smartswitch

How I did it

  • Support new database configuration
{
    "INCLUDES" : [
        {
            "include" : "../../redis/sonic-db/database_config.json"
        },
        {
            "database_name" : "dpu0",
            "include" : "../../redisdpu0/sonic-db/database_config.json"
        }
    ],
    "VERSION" : "1.0"
}

Use a single layer instance for each device to support multiple asic and multiple dpu.
For example, for multiple asic, the instances can be named localhost, asic0, asic1, and so on. For multiple dpu, the instances can be named localhost, dpu0, dpu1, and so on. For multiple asic npu and multiple dpu, the instances can be named localhost, asic0, asic1, ..., dpu0, dpu1, and so on.

        "DPU_APPL_DB" : {
            "id" : 15,
            "separator": ":",
            "instance" : "redis",
            "format": "proto"
        },

We are trying to modify DPU_APPL_DB with GNMI, but the database is not accessible by swsscommon. This is because DPU_APPL_DB is a new database defined in /var/run/redisdpu0/sonic-db/database_config.json. As a workaround, we use GNMI to modify APPL_DB instead, but we need to update swsscommon to support the new database configuration.

  • Update GNMI path to support multiple database

I add a new element in GNMI path to support database instance.

/APPL_DB/dpu0/DASH_VNET_TABLE/vnet1/

The second element is used for target database instance, and it can be localhost, asic0, asic1, ..., dpu0, dpu1, and so on.
If SONiC device is not multi-asic or multi-dpu, this second element should be localhost.

This design is not backward compatible.

How to verify it

Run unit test for sonic-gnmi.
Run end to end test for dash and gnmi.

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

@ganglyu ganglyu requested a review from Pterosaur December 9, 2023 01:24
@ganglyu ganglyu force-pushed the support_dpu_database branch from bd02b15 to f310689 Compare December 9, 2023 08:21
@ganglyu ganglyu requested a review from liuh-80 December 9, 2023 08:49

path, _ := os.Getwd()
path = filepath.Dir(path)

var cmd *exec.Cmd
cmd = exec.Command("bash", "-c", "cd "+path+" && "+"pytest")
cmd = exec.Command("bash", "-c", "cd "+path+" && "+"pytest -m 'not dpu'")
Copy link
Collaborator

@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.

-m 'not dpu'

Could you add some comment to explain the intention? #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

@@ -3861,6 +3861,41 @@ print('%s')
s.s.Stop()
}

// Test DPU configuration with multiple databases
Copy link
Collaborator

Choose a reason for hiding this comment

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

DPU

This PR is gnmi general support the multi-db feature, not specific related to DPU, but also multi-asic, even single-asic with multiple database. Could you generalize naming/comments/etc ?

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

Copy link
Collaborator

@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.

also generalize the PR title?

@ganglyu ganglyu requested a review from qiluo-msft December 12, 2023 07:49
@@ -168,7 +185,8 @@ func GetDbTcpAddr(db_name string, ns string) string {
return hostname + ":" + strconv.Itoa(port)
}

func DbGetNamespaceAndConfigFile(ns_to_cfgfile_map map[string]string) {
func DbParseConfigFile(name_to_cfgfile_map map[string]string) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

DbParseConfigFile

Let's explore using swss-common SonicDBConfig class instead of reimplementing in this file. We can raise another PR, and let this PR depending on that PR.

@ganglyu ganglyu closed this Mar 18, 2024
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.

2 participants