8000 Add a new API connect_host to SonicV2Connector by vivekverma-arista · Pull Request #1003 · sonic-net/sonic-swss-common · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add a new API connect_host to SonicV2Connector #1003

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

Closed
wants to merge 5 commits into from

Conversation

vivekverma-arista
Copy link
@vivekverma-arista vivekverma-arista commented Apr 9, 2025

This feature has been tracked in #1543
HLD PR: 1957

What did I do?

A new API is being added to sonicv2connector.cpp which can take the db name and host IP as an argument and connect us to the redis instance. The existing API needs the db_name and the host_ip and port (or unix_socket) is decoded using database_config.json. This API is tailored for use cases when you want to connect to the namespace redis instances from the same device. Our use case of aggregating VOQ counters across NPUs involves connecting to a redis instances over midplane IP hence the new API is needed.

How did I test it?

Existing unit test test_redis_ut.py is modified to test this. Also verified on Arista chassis (DCS-7804-CH) which had 7800R3A-36D2-LC linecards with all changes related to this feature as present here sonic-net/SONiC#1957

@mssonicbld
Copy link
Collaborator

/azp run

Copy link
Azure Pipelines successfully started running 1 pipeline(s).

Enhance test_redis_ut.py.
@mssonicbld
Copy link
Collaborator

/azp run

< 8000 input type="hidden" data-csrf="true" name="authenticity_token" value="FhVsoxKDbvAMZox+c/KOmDcXGKHjDHPA7JsK44kWKvgyUVe4IbNj9MHocIowqdVdMRVpyEDbyRm/BVs7IizZzQ==" />

Copy link
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link
Azure Pipelines successfully started running 1 pipeline(s).

@kenneth-arista
Copy link

@arlakshm @vmittal-msft this is needed for the aggregate Voq counters feature

@vmittal-msft vmittal-msft self-requested a review May 21, 2025 17:24
@abdosi
Copy link
Contributor
abdosi commented Jun 4, 2025

@qiluo-msft @liuh-80 : can you please review this.

@vmittal-msft
Copy link

LGTM. please rebase.

@mssonicbld
Copy link
Collaborator

/azp run

Copy link
Azure Pipelines successfully started running 1 pipeline(s).

@vivekverma-arista
Copy link
Author

@qiluo-msft please help in merging this PR

db = SonicV2Connector(use_unix_socket_path=True, namespace='', decode_responses=True)
db = SonicV2Connector(use_unix_socket_path=False, decode_responses=True)
db = SonicV2Connector(host="127.0.0.1", decode_responses=True)
db = SonicV2Connector()
Copy link
Contributor

Choose a reason for hiding this comment

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

connect_host

Class SonicV2Connector is for historic compatible purpose. For your use case, I believe DBConnector is what your need, providing your all the flexibility to connect to a host and port. Could you explore?

Copy link
Author

Choose a reason for hiding this comment

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

Looks like in the queuestat: https://github.com/sonic-net/sonic-swss-common/blob/master/common/dbconnector.cpp#L655-L664 can be used. But it will need significant adjustments in the unit test in our case.

The infra for mimicking SonicV2Connector is already in place, it may not be easy to do that with DBConnector

https://github.com/sonic-net/sonic-utilities/blob/master/tests/mock_tables/dbconnector.py#L231-L240

Copy link
Contributor
@qiluo-msft qiluo-msft Jun 26, 2025

Choose a reason for hiding this comment

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

We should first discuss which design fit your needs more properly. The effort of test adjustments and how to mimicking should not revert the design decision. Sorry if you already spend time on testcode, but we need to be careful when extending interfaces in swss-common repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

6 participants
0