Skip to content

Commit 73cbfbe

Browse files
aldenh-viamdgottliebcheukt
authored
RSDK-9327: Dynamically check safety_heartbeat_monitored RPC option to decide if Sessions should be used (#5011)
Co-authored-by: Dan Gottlieb <dan.gottlieb@viam.com> Co-authored-by: Cheuk <90270663+cheukt@users.noreply.github.com>
1 parent 413cd4b commit 73cbfbe

File tree

4 files changed

+255
-216
lines changed

4 files changed

+255
-216
lines changed

robot/client/client_session.go

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,14 @@ import (
1414
"google.golang.org/grpc/status"
1515

1616
"go.viam.com/rdk/resource"
17+
"go.viam.com/rdk/robot"
1718
"go.viam.com/rdk/session"
1819
)
1920

2021
type ctxKey byte
2122

2223
const ctxKeyInSessionMDReq = ctxKey(iota)
2324

24-
var exemptFromSession = map[string]bool{
25-
"/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo": true,
26-
"/proto.rpc.webrtc.v1.SignalingService/Call": true,
27-
"/proto.rpc.webrtc.v1.SignalingService/CallUpdate": true,
28-
"/proto.rpc.webrtc.v1.SignalingService/OptionalWebRTCConfig": true,
29-
"/proto.rpc.v1.AuthService/Authenticate": true,
30-
"/proto.rpc.v1.ExternalAuthService/AuthenticateTo": true,
31-
"/viam.robot.v1.RobotService/ResourceNames": true,
32-
"/viam.robot.v1.RobotService/ResourceRPCSubtypes": true,
33-
"/viam.robot.v1.RobotService/StartSession": true,
34-
"/viam.robot.v1.RobotService/SendSessionHeartbeat": true,
35-
}
36-
3725
func (rc *RobotClient) sessionReset() {
3826
rc.sessionMu.Lock()
3927
rc.sessionsSupported = nil
@@ -102,7 +90,7 @@ func (rc *RobotClient) sessionMetadata(ctx context.Context, method string) (cont
10290
return rc.sessionMetadataInner(ctx), nil
10391
}
10492
rc.sessionMu.RUnlock()
105-
93+
// upgrade lock
10694
rc.sessionMu.Lock()
10795
defer rc.sessionMu.Unlock()
10896

@@ -166,7 +154,7 @@ func (rc *RobotClient) safetyMonitorFromHeaders(ctx context.Context, hdr metadat
166154
}
167155

168156
func (rc *RobotClient) useSessionInRequest(ctx context.Context, method string) bool {
169-
return !rc.sessionsDisabled && !exemptFromSession[method] && ctx.Value(ctxKeyInSessionMDReq) == nil
157+
return !rc.sessionsDisabled && ctx.Value(ctxKeyInSessionMDReq) == nil && robot.IsSafetyHeartbeatMonitored(method)
170158
}
171159

172160
func (rc *RobotClient) sessionUnaryClientInterceptor(

0 commit comments

Comments
 (0)