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

gNMI subscription for translib managed YANG data #1287

Merged
merged 13 commits into from
May 27, 2023

Conversation

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Mar 15, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.


SONiC Telemetry service suports gNMI Get, Set and Subscribe RPCs for DB paths and sonic-yang based paths.
It also suppots Get and Set for OpenConfig and IETF yang based paths that are part of **sonic-mgmt-common** repository.
This design document describes proposed enhancements to support gNMI Subscribe RPC for such YANG paths.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please be explicit here that this HLD adds the subscription feature for openconfig models based on translib infra part of sonic-mgmt-common?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done


## 8 Unit Tests

Following unit test cases require app code changes to handle subscription.
Copy link
Collaborator

@venkatmahalingam venkatmahalingam Mar 28, 2023

Choose a reason for hiding this comment

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

What UT/FT cases will be added for this infra code if no app code changes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We will either enhance some of the existing app module code or introduce temporary test yangs.

The request `target` will be made optional.
Request will be processed as described in [GRPC Telemetry HLD](../../system-telemetry/grpc_telemetry.md)
if the `target` is specified and matches one of the reserved keywords listed in that HLD.
If `target` is not specified or not one of the reserved ones, the subscribe path will be treated as tarnslib YANG path.
Copy link
Contributor

Choose a reason for hiding this comment

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

@qiluo-msft , @zbud-msft , do we plan to use any other target, if yes, then this would break our future use cases.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@lguohan & team -- did not hear any responses for this. Anyway, I now have proposed a origin based identification of OpenConfig YANG paths. Existing target based identification of DB/event/virtual paths will be retained when client did not specify an origin. Please check.
However this target based identification is a violation of the gNMI specification. Please consider using origin instead of target.

@qiluo-msft qiluo-msft requested a review from ganglyu March 29, 2023 20:18
sachinholla added a commit to sachinholla/sonic-mgmt-common that referenced this pull request Mar 31, 2023
Added new translateSubscribe() and processSubscribe() functions to
appInterface as per HLD sonic-net/SONiC#1287

Also added stub implementation of these functions to all existing app
modules. It blindly treats all paths as non-db. Basic subscription
features, without on_change, are enabled with this mapping.

Signed-off-by: Sachin Holla <[email protected]>
sachinholla added a commit to sachinholla/sonic-mgmt-common that referenced this pull request Mar 31, 2023
Added new translateSubscribe() and processSubscribe() functions to
appInterface as per HLD sonic-net/SONiC#1287

Also added stub implementation of these functions to all existing app
modules. It blindly treats all paths as non-db. Basic subscription
features, without on_change, can be verified with this mapping.

Signed-off-by: Sachin Holla <[email protected]>

SONiC Telemetry service suports gNMI Get, Set and Subscribe RPCs for DB paths and sonic-yang based paths.
It also suppots Get and Set for OpenConfig and IETF yang based paths that are part of **sonic-mgmt-common** repository.
This design document describes proposed enhancements to support gNMI Subscribe RPC for such YANG paths.
Copy link
Contributor

@qiluo-msft qiluo-msft Mar 31, 2023

Choose a reason for hiding this comment

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

YANG paths

How about sonic-yang paths? If out of scope of this HLD, do you evaluate the possibility and effort needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sonic yang paths are not considering it in this HLD. But it can be easily supported in future if needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see some of the requirements are useful for sonic-yang paths, and for sonic-db paths. For example TARGET_DEFINED/POLL and ONCE/Wildcard Keys.

It would be nice if the requirement could be implemented onto all the possible path types.

Copy link
Collaborator Author

@sachinholla sachinholla May 18, 2023

Choose a reason for hiding this comment

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

Translib can handle sonic-yang paths. We are planning to implement in a future release.

sonic-db paths cannot be be handled in translib. You need to enhance the DbClient implementation to handle all other subscription modes. This HLD is applicable for TranslClient only.


### 1.2 Requirements

#### 1.2.1 ON_CHANGE subscription for eligible paths
Copy link
Contributor

@qiluo-msft qiluo-msft Mar 31, 2023

Choose a reason for hiding this comment

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

ON_CHANGE subscription

ON_CHANGE subscription is not limited to openconfig yang models. How about the support on sonic-yang paths, non-db paths? #Pending

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This HLD only covers the yang paths handled by translib.

@qiluo-msft
Copy link
Contributor

@hui-ma Please help review.

#### 1.2.3 TARGET_DEFINED subscription for all paths

Infrastructure should support TARGET_DEFINED subscription for all YANG paths.
Subscribe request should be treated as ON_CHANGE or SAMPLE based on the app's preferences for the target path.
Copy link
Contributor

@qiluo-msft qiluo-msft Mar 31, 2023

Choose a reason for hiding this comment

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

app's preferences

What is "app's preferences"? #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Subscription preferences for a yang path as set by the app module. Section 2.5 has more details.


Infrastructure should support TARGET_DEFINED subscription for all YANG paths.
Subscribe request should be treated as ON_CHANGE or SAMPLE based on the app's preferences for the target path.
It should split into multiple requests if the target path supports ON_CHANGE
Copy link
Contributor

@qiluo-msft qiluo-msft Mar 31, 2023

Choose a reason for hiding this comment

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

It should split into multiple requests

Who should split what into multiple requests?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Translib infra

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain "It should split into multiple requests if the target path supports ON_CHANGE"? Better with an example?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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


Infrastructure should support POLL and ONCE subscriptions for all YANG paths.

#### 1.2.5 Support Wildcard Keys
Copy link
Contributor

@qiluo-msft qiluo-msft Mar 31, 2023

Choose a reason for hiding this comment

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

Wildcard Keys

wildcard is not limited to openconfig yang models. How about the support on sonic-yang paths, non-db paths, db paths? #Pending

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This HLD only covers the yang paths handled by translib.

Apps should be allowed to indicate wildcard unsupported paths.
An `INVALID_ARGUMENT` status should be returned if wildcard key cannot be supported for the target path.

Wildcard in path element (like `/interfaces/*/config` or `/interfaces/.../config`) is a stretch goal.
Copy link
Contributor

@qiluo-msft qiluo-msft Mar 31, 2023

Choose a reason for hiding this comment

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

stretch goal

You must have some basic goals. Could you list them explicitly? #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Supporting wildcard keys is the basic goal (section heading). I will remove this line to avoid confusion.

### 1.3 Translib Overview

Translib is a golang library for reading and writing YANG model based data to redis DB or non-DB data source.
Applications would plugin the YANG models and their translation code into the translib.
Copy link
Contributor

@qiluo-msft qiluo-msft Mar 31, 2023

Choose a reason for hiding this comment

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

Applications

The term "Applications" is easy to mislead to user mode process running inside sonic. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will try to rephrase

Apps should implement a *path transformer* to handle special cases --
subtree transformer or when there is no one-to-one mapping of YANG key to DB key.

### 2.2 Identifying YANG Based Subscriptions
Copy link
Contributor

@qiluo-msft qiluo-msft Mar 31, 2023

Choose a reason for hiding this comment

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

@ganglyu Please help check this section. #Closed

### 2.4 Streaming Data from Translib

Unlike Get, translib will be returning multiple responses while processing the subscribe request.
To handle this, the gNMI server would pass a queue to translib and wait for the response on it.
Copy link
Contributor

@qiluo-msft qiluo-msft Mar 31, 2023

Choose a reason for hiding this comment

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

queue

How to you limit the queue size? Is it possible that the queue size will be infinite? Is it possible that queue is full and notification will drop internally? #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There should not be any silent drops. We are re-using the existing PriorityQueue of client_subscribe.go. I do not see any queue size related handling there. Behavior will be same as that of the existing DbClient or NonDbClient (with respect to the response queue management).

@jeff-yin
Copy link

jeff-yin commented May 9, 2023

Please add sonic-mgmt-common#81 (Transformer UT) to the PR list. I can't edit the main text of this PR.

| *{empty}* | *{empty}* | Error (existing logic) |
| *{empty}* | *{unknown}* | Error |
| *{unknown}* | *{opaque}* | Error |

Copy link
Contributor

@ganglyu ganglyu May 18, 2023

Choose a reason for hiding this comment

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

Please check https://github.com/sonic-net/SONiC/blob/master/doc/mgmt/gnmi/SONiC_GNMI_Server_Interface_Design.md 1.2.1.3 Data Schema.
This table does not align with our decision tree, would you please update decision tree?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had referred that section earlier. That HLD only addresses schema identification for Get and Set rpcs. It does not talk about the Subscribe rpc. However, I saw few discrepancies in the implementation -- the Get & Set code is looking for origin=sonic-db only. I could not find any handling for origin=sonic-yang or origin=sonic_yang as described in the HLD.

The proposal in the current HLD is applicable for Subscribe rpc alone. It does not affect the Get and Set handling. Also, it is in alignment with decision matrix from the other HLD. It only looks different because it does not talk about origin values "sonic-db" and "sonic-yang". We do not support sonic yang based subscription as of now. Hence origin=sonic-yang is not applicable for the current HLD. Similarly, origin=sonic-db is not included because the existing code uses a target based path identification for DB, non-DB and events paths; and we cannot change it without breaking the backward compatibility.

Copy link
Contributor

Choose a reason for hiding this comment

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

sonic-yang is not implemented for now.
For the Subscribe rpc, we might need to support sonic-db and sonic-yang. This requires a decision tree to handle different scenarios for this rpc. The existing code uses target and origin="", so supporting origin=sonic-db should not affect backward compatibility.

Copy link
Contributor

@ganglyu ganglyu May 18, 2023

Choose a reason for hiding this comment

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

And the logic of decision tree could be:

if origin == 'openconfig':
# translib subscribe
elif origin == 'sonic-db':
# sonic db subscribe
elif origin == 'sonic-yang':
# sonic yang subscribe
else:
# existing subscribe implementation

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As discussed in yesterday's meeting, the scope of this HLD is to support subscription for openconfig yang paths only. Hence I have not included anything about origin=sonic-yang in this HLD to avoid confusion. We do have plans to extend it to sonic ynag paths in a future release. Decision table will be updated at that time.

For sonic-db paths, the current implementation uses a different logic and we do not want to touch it -- for backward compatibility with existing clients. The path structure used also slightly differs from your HLD; please refer to SONiC gRPC Telemetry HLD. There are other path types, like non-DB path, event path etc. Hence we are asking the owners of those components (I guess Microsoft) to enhance them.

Copy link

@tomek-US tomek-US left a comment

Choose a reason for hiding this comment

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

LGTM

@zhangyanzhao
Copy link
Collaborator

only two open code PRs left, nice!

@skg-net
Copy link
Member

skg-net commented Jan 31, 2024

@adyeung Can you please update the Quality Metric (Alpha/Beta/GA) for the feature either in this PR comments or in HLD itself based on https://github.com/sonic-net/SONiC/blob/master/doc/SONiC%20feature%20quality%20definition.md

@adyeung
Copy link
Collaborator

adyeung commented Jan 31, 2024

Please mark Quality Metric as Alpha for this feature

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.