feat: reconcile retained client commands
This commit is contained in:
@@ -185,15 +185,14 @@ func (server *AgentServer) serveConnection(parent context.Context, connection *w
|
||||
return
|
||||
}
|
||||
if snapshot := envelope.GetReconcileSnapshot(); snapshot != nil {
|
||||
// A retained command requires the command-store reconciliation phase,
|
||||
// which is deliberately not substituted with a no-op result.
|
||||
if len(snapshot.GetRetainedCommands()) != 0 {
|
||||
server.close(connection, websocket.StatusPolicyViolation, "reconciliation for retained commands is unavailable")
|
||||
result, reconcileErr := server.Store.ReconcileClientSnapshot(sessionContext, hello.GetClientId(), snapshot)
|
||||
if reconcileErr != nil {
|
||||
server.close(connection, websocket.StatusPolicyViolation, "reconciliation failed")
|
||||
return
|
||||
}
|
||||
encoded, err := proto.Marshal(&rvboxv1.AgentEnvelope{
|
||||
SessionId: encodedSessionID, SessionGeneration: registration.Generation,
|
||||
Payload: &rvboxv1.AgentEnvelope_ReconcileResult{ReconcileResult: &rvboxv1.ReconcileResult{}},
|
||||
Payload: &rvboxv1.AgentEnvelope_ReconcileResult{ReconcileResult: result},
|
||||
})
|
||||
if err != nil || queue.EnqueueControl(Frame{Kind: FrameControl, Payload: encoded}) != nil {
|
||||
server.close(connection, websocket.StatusInternalError, "could not queue reconciliation result")
|
||||
|
||||
Reference in New Issue
Block a user