k8s-operator,sessionrecording: fixing race condition between resize (#16454)

messages and cast headers when recording `kubectl attach` sessions

Updates #16490

Signed-off-by: chaosinthecrd <tom@tmlabs.co.uk>
This commit is contained in:
Tom Meadows
2025-07-14 15:17:20 +01:00
committed by GitHub
parent f23e4279c4
commit bcaea4f245
10 changed files with 351 additions and 243 deletions

View File

@@ -10,13 +10,13 @@ package fakes
import (
"bytes"
"encoding/json"
"fmt"
"math/rand"
"net"
"sync"
"testing"
"time"
"math/rand"
"tailscale.com/sessionrecording"
"tailscale.com/tstime"
)
@@ -107,7 +107,13 @@ func CastLine(t *testing.T, p []byte, clock tstime.Clock) []byte {
return append(j, '\n')
}
func AsciinemaResizeMsg(t *testing.T, width, height int) []byte {
func AsciinemaCastResizeMsg(t *testing.T, width, height int) []byte {
msg := fmt.Sprintf(`[0,"r","%dx%d"]`, height, width)
return append([]byte(msg), '\n')
}
func AsciinemaCastHeaderMsg(t *testing.T, width, height int) []byte {
t.Helper()
ch := sessionrecording.CastHeader{
Width: width,