-
Notifications
You must be signed in to change notification settings - Fork 123
RSDK-9327: Dynamically check safety_heartbeat_monitored RPC option to decide if Sessions should be used #5011
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
Conversation
Tests are failing because |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good to me! Just some questions and nits.
@@ -139,7 +151,7 @@ func (m *SessionManager) UnaryServerInterceptor( | |||
info *grpc.UnaryServerInfo, | |||
handler grpc.UnaryHandler, | |||
) (interface{}, error) { | |||
if exemptFromSession[info.FullMethod] { | |||
if _, _, isMonitored := m.safetyMonitoredTypeAndMethod(info.FullMethod); !isMonitored { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just use IsSafetyHeartbeatMonitored
so you don't have to ignore the first two return values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
safetyMonitoredTypeAndMethod
retrieves the method descriptor from the Robot (via a registry we manage ourselves), while the other gets it from protobuf's registry (populated as side effects of importing). It should be functionally the same, but the rest of the Interceptors code (m.safetyMonitoredResourceFromUnary
/m.safetyMonitoredResourceFromStream
) reaches into the Robot as well, so if there are no strong opinions either way, I'll leave it for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally looks good, can you also update session/doc.go to reflect current behavior?
Co-authored-by: Cheuk <90270663+cheukt@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Per offline discussion: do we need sessionStreamClientInterceptor
at all anymore? /Are we interested in attaching sessions to streams? Seems like we have no streaming APIs that need "safety" for actuation.
Not for now (the only streaming RPC that currently has |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
The current client implementation checks a blacklist on each RPC call:
rdk/robot/client/client_session.go
Lines 24 to 35 in 3de60f9
rdk/robot/client/client_session.go
Lines 122 to 132 in 3de60f9
This change, based on viamrobotics/viam-python-sdk#857, tests ex-ante if the
safety_heartbeat_monitored
RPC option is set (example), and will only start try StartSession if so (true = session; false/unspecified = no session). Reminder: one session at most per client (it initiates with the first RPC call that requires one).Note,
useSessionInRequest
(and thus the newisSafetyHeartbeatMonitored
) is appears to be called more times than necessary. It's called inside both the Unary (every time) and Stream (on first msg) interceptors before they callsessionMetadata
that also calls it. I can look into reworking this if needed.