Skip to content

Commit 0a659df

Browse files
committed
rpcserver: remove session after registration error
1 parent a18c0b6 commit 0a659df

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

session_rpcserver.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,17 @@ func (s *sessionRpcServer) AddAutopilotSession(ctx context.Context,
12861286
privacyFlags.Serialize(),
12871287
)
12881288
if err != nil {
1289+
// If we tried to link to a previous session, we delete the
1290+
// newly created session in the case of errors to avoid having
1291+
// non-revoked sessions lying around.
1292+
if len(req.LinkedGroupId) != 0 {
1293+
deleteErr := s.cfg.db.DeleteReservedSession(
1294+
ctx, sess.ID,
1295+
)
1296+
log.Errorf("error deleting session after failed "+
1297+
"linking attempt: %v", deleteErr)
1298+
}
1299+
12891300
return nil, fmt.Errorf("error registering session with "+
12901301
"autopilot server: %v", err)
12911302
}

0 commit comments

Comments
 (0)