Skip to content

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

Merged
merged 22 commits into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
fe524d4
add isSafetyHeartbeatMonitored to check at runtime for safety_heartbe…
aldenh-viam May 28, 2025
4e9aae5
Remove redundant exemptFromSession hardcoded map
aldenh-viam May 28, 2025
aff8f29
Update, simplify, and document TestClientSessionResume
aldenh-viam Jun 5, 2025
e46141c
Update, simplify, and document TestClientSessionExpiration
aldenh-viam Jun 5, 2025
b60513f
Update, simplify, and document TestClientSessionOptions
aldenh-viam Jun 5, 2025
f3006e4
add period (lint)
aldenh-viam Jun 5, 2025
2d4af06
fix import order (lint)
aldenh-viam Jun 5, 2025
a85a250
Revert "fix import order (lint)"
aldenh-viam Jun 5, 2025
ed062ad
fix import order (lint)
aldenh-viam Jun 5, 2025
ab1a816
Revert "fix import order (lint)"
aldenh-viam Jun 5, 2025
58def75
fix import order (lint)
aldenh-viam Jun 5, 2025
8e9638d
fix import order (lint)
aldenh-viam Jun 5, 2025
91f83c9
reorder imports
dgottlieb Jun 5, 2025
706ec0a
dynamically check for safety_heartbeat_monitored RPC option before pr…
aldenh-viam Jun 5, 2025
f799465
refactor: use shared IsSafetyHeartbeatMonitored from session_web
aldenh-viam Jun 5, 2025
4a097d0
fix import order (lint)
aldenh-viam Jun 5, 2025
d7727b7
update function name in debug stmt
aldenh-viam Jun 9, 2025
2e15a80
update doc
aldenh-viam Jun 9, 2025
8b2f790
remove copy of loop variables; no longer needed with Go 1.22
aldenh-viam Jun 9, 2025
20593a5
remove expected session panics; test ok instead
aldenh-viam Jun 9, 2025
078a024
remove unused SafetyMonitorResourceName
aldenh-viam Jun 9, 2025
892194b
speedup; don't use rich descriptors when regular suffices
aldenh-viam Jun 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions robot/client/client_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,14 @@ import (
"google.golang.org/grpc/status"

"go.viam.com/rdk/resource"
"go.viam.com/rdk/robot"
"go.viam.com/rdk/session"
)

type ctxKey byte

const ctxKeyInSessionMDReq = ctxKey(iota)

var exemptFromSession = map[string]bool{
"/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo": true,
"/proto.rpc.webrtc.v1.SignalingService/Call": true,
"/proto.rpc.webrtc.v1.SignalingService/CallUpdate": true,
"/proto.rpc.webrtc.v1.SignalingService/OptionalWebRTCConfig": true,
"/proto.rpc.v1.AuthService/Authenticate": true,
"/proto.rpc.v1.ExternalAuthService/AuthenticateTo": true,
"/viam.robot.v1.RobotService/ResourceNames": true,
"/viam.robot.v1.RobotService/ResourceRPCSubtypes": true,
"/viam.robot.v1.RobotService/StartSession": true,
"/viam.robot.v1.RobotService/SendSessionHeartbeat": true,
}

func (rc *RobotClient) sessionReset() {
rc.sessionMu.Lock()
rc.sessionsSupported = nil
Expand Down Expand Up @@ -102,7 +90,7 @@ func (rc *RobotClient) sessionMetadata(ctx context.Context, method string) (cont
return rc.sessionMetadataInner(ctx), nil
}
rc.sessionMu.RUnlock()

// upgrade lock
rc.sessionMu.Lock()
defer rc.sessionMu.Unlock()

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

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

func (rc *RobotClient) sessionUnaryClientInterceptor(
Expand Down
Loading
Loading