[meta] Add opt-in saithrift RPCs for draining SAI notifications - #2335
Open
nicholasching wants to merge 2 commits into
Open
[meta] Add opt-in saithrift RPCs for draining SAI notifications#2335nicholasching wants to merge 2 commits into
nicholasching wants to merge 2 commits into
Conversation
Signed-off-by: Nicholas Ching <nicholaslching@gmail.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
| } | ||
|
|
||
| struct sai_thrift_notification_event_t { | ||
| 1: i32 notification_type; |
There was a problem hiding this comment.
can we define enum type for notification type?
Contributor
Author
|
Hi @kcudnik @tjchadaga, when you have a chance, could you please invoke azure pipelines to run checks. Thanks! |
Signed-off-by: Nicholas Ching <nicholaslching@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context / motivation
Part of the SAIVPP unit-test framework. SAI delivers port state and BFD session state asynchronously through function pointers written into
SAI_SWITCH_ATTR_PORT_STATE_CHANGE_NOTIFYandSAI_SWITCH_ATTR_BFD_SESSION_STATE_CHANGE_NOTIFY. A Thrift client cannot supply a function pointer, so there is currently no way for any saithrift-based test suite to observe that a notification was delivered. This blocks testing the notification path on any target, not just VPP.What this change does
meta/templates/sai_thrift_utils.tt,meta/templates/sai.thrift.tt. Declaresai_thrift_enable_notifications()andsai_thrift_drain_notifications(), plus asai_thrift_notification_event_trecord carrying notification type, object id and state.meta/templates/sai_rpc_server_functions.tt. Add the two method names to thesai_utils_functionsregex so the generator emits stub bodies instead of trying to bind them to SAI metadata.meta/sai_rpc_frontend.cpp. Implement both methods insai_rpcHandlerFrontend, following the existingsai_thrift_object_type_get_availabilitypattern. The enable RPC installs server-owned callbacks and is idempotent; the drain RPC is non-blocking and atomically empties a mutex-protected bounded queue.set_switch_attribute, not at create time.SwitchStateBase::set_switch_default_attributes()writes NULL into both attributes duringinitialize_default_objects, so a pointer supplied at create time is silently discarded. Both attributes areCREATE_AND_SETand the senders re-read them when an event fires, so a post-create set is correct, simpler, and additionally suppresses the forced port-UP notifications raised during host-interface creation.Scope / risk
saiserver; only notification type, object id and state are serialized.gensairpc.plcompletes and the generated service contains both methods;saithriftv2andsaiserverbuild and link; enable followed by drain from a throwaway client returns an empty list without crashing. End-to-end validation is in the notification test PR.Dependencies
None. This is a prerequisite for the notification test cases, #2336.