fix (worker): send workerId when authorizing session (#2207)
* fix (worker): send workerId when authorizing session Send the workerId returned from the last success worker status when authorizing a session. * fixup! fix (worker): send workerId when authorizing session * fixup! fix (worker): send workerId when authorizing session * refactor (worker): deprecate workerId in ActivateSessionRequest It wasn't being used anywho * fixup! fix (worker): send workerId when authorizing session * Update LookupSessionRequest Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
This commit is contained in:
1 parent
66a3fe6106
commit
bd167da7d1
6 files changed
+95
-118
No files matched your search
@@ -137,7 +137,6 @@ func (w *Worker) handleProxy(listenerCfg *listenerutil.ListenerConfig) (http.Han
|
||||
}
|
||||
return
|
||||
}
|
||||
workerId := w.conf.RawConfig.Worker.Name
|
||||
|
||||
var handshake proxy.ClientHandshake
|
||||
if err := wspb.Read(connCtx, conn, &handshake); err != nil {
|
||||
@@ -187,7 +186,7 @@ func (w *Worker) handleProxy(listenerCfg *listenerutil.ListenerConfig) (http.Han
|
||||
return
|
||||
}
|
||||
if handshake.Command == proxy.HANDSHAKECOMMAND_HANDSHAKECOMMAND_UNSPECIFIED {
|
||||
sessStatus, err = session.Activate(ctx, sessClient, workerId, sessionId, handshake.GetTofuToken(), version)
|
||||
sessStatus, err = session.Activate(ctx, sessClient, sessionId, handshake.GetTofuToken(), version)
|
||||
if err != nil {
|
||||
event.WriteError(ctx, op, err, event.WithInfoMsg("unable to validate session"))
|
||||
if err = conn.Close(websocket.StatusInternalError, "unable to activate session"); err != nil {
|
||||
@@ -216,6 +215,15 @@ func (w *Worker) handleProxy(listenerCfg *listenerutil.ListenerConfig) (http.Han
|
||||
return
|
||||
}
|
||||
|
||||
if w.LastStatusSuccess() == nil || w.LastStatusSuccess().WorkerId == "" {
|
||||
event.WriteError(ctx, op, errors.New("worker id is empty"))
|
||||
if err = conn.Close(websocket.StatusInternalError, "worker id is empty"); err != nil {
|
||||
event.WriteError(ctx, op, err, event.WithInfoMsg("error closing client connection"))
|
||||
}
|
||||
return
|
||||
}
|
||||
workerId := w.LastStatusSuccess().WorkerId
|
||||
|
||||
var ci *session.ConnInfo
|
||||
var connsLeft int32
|
||||
ci, connsLeft, err = session.AuthorizeConnection(ctx, sessClient, workerId, sessionId)
|
||||
|
||||
Reference in new issue
Block a user