This commit is contained in:
2025-07-23 18:41:30 +08:00
parent a9add11578
commit 730a7fb8c0
12 changed files with 57 additions and 3 deletions

View File

@@ -109,7 +109,13 @@ func chainUnaryInterceptors(interceptors []UnaryClientInterceptor, final Invoker
// NewClient creates a new ttrpc client using the given connection
func NewClient(conn net.Conn, opts ...ClientOpts) *Client {
a := log.Fields{
"mzq-test": true,
"conn": fmt.Sprintf("%+v", conn),
"opts": fmt.Sprintf("%+v", opts),
}
ctx, cancel := context.WithCancel(context.Background())
log.G(ctx).WithFields(a).Info("client.go NewClient")
channel := newChannel(conn)
c := &Client{
codec: codec{},
@@ -368,7 +374,12 @@ func (c *Client) receiveLoop() error {
sid := streamID(msg.header.StreamID)
s := c.getStream(sid)
if s == nil {
log.G(c.ctx).WithField("stream", sid).Error("ttrpc: received message on inactive stream")
a := log.Fields{
"mzq-test": true,
"stream": sid,
"c": fmt.Sprintf("%+v", c),
}
log.G(c.ctx).WithFields(a).Errorf("ttrpc: received message on inactive stream")
continue
}

View File

@@ -219,6 +219,7 @@ func (conn *Conn) Open(w http.ResponseWriter, req *http.Request) (string, []io.R
serveHTTPComplete := make(chan struct{})
// Ensure panic in spawned goroutine is propagated into the parent goroutine.
panicChan := make(chan any, 1)
klog.Infof("mzq-test, conn.go Open, req: %+v, req.Body: %+v, conn: %+v, timeout: %+v\n", req, req.Body, conn, conn.timeout.String())
go func() {
// If websocket server returns, propagate panic if necessary. Otherwise,
// signal HTTPServe finished by closing "serveHTTPComplete".
@@ -336,7 +337,7 @@ func (conn *Conn) handle(ws *websocket.Conn) {
var data []byte
if err := websocket.Message.Receive(ws, &data); err != nil {
if err != io.EOF {
klog.Errorf("Error on socket receive: %v", err)
klog.Errorf("mzq-test, Error on socket receive: %v, ws: %+v, data: %v", err, ws, string(data))
}
break
}

View File

@@ -114,6 +114,7 @@ func handleWebSocketStreams(req *http.Request, w http.ResponseWriter, portForwar
},
})
conn.SetIdleTimeout(idleTimeout)
klog.Infof("mzq-test, portforward/websocket.go, idleTimeout: %+v, req: %+v, req.body: %+v, podName: %v, uid: %v, opts: %+v, portForwarder: %+v, supportedPortForwardProtocols: %+v, streamCreationTimeout: %+v\n", idleTimeout.String(), req.Body, podName, uid, portForwarder, supportedPortForwardProtocols, streamCreationTimeout.String())
_, streams, err := conn.Open(responsewriter.GetOriginal(w), req)
if err != nil {
err = fmt.Errorf("unable to upgrade websocket connection: %v", err)

View File

@@ -40,6 +40,7 @@ type Attacher interface {
// ServeAttach handles requests to attach to a container. After creating/receiving the required
// streams, it delegates the actual attaching to attacher.
func ServeAttach(w http.ResponseWriter, req *http.Request, attacher Attacher, podName string, uid types.UID, container string, streamOpts *Options, idleTimeout, streamCreationTimeout time.Duration, supportedProtocols []string) {
fmt.Println("mzq-test, remotecommand/attach.go ServeAttach")
ctx, ok := createStreams(req, w, streamOpts, supportedProtocols, idleTimeout, streamCreationTimeout)
if !ok {
// error is handled by createStreams

View File

@@ -43,6 +43,7 @@ type Executor interface {
// creating/receiving the required streams, it delegates the actual execution
// to the executor.
func ServeExec(w http.ResponseWriter, req *http.Request, executor Executor, podName string, uid types.UID, container string, cmd []string, streamOpts *Options, idleTimeout, streamCreationTimeout time.Duration, supportedProtocols []string) {
fmt.Println("mzq-test, remotecommand/exec.go ServeExec")
ctx, ok := createStreams(req, w, streamOpts, supportedProtocols, idleTimeout, streamCreationTimeout)
if !ok {
// error is handled by createStreams

View File

@@ -95,6 +95,7 @@ func createWebSocketStreams(req *http.Request, w http.ResponseWriter, opts *Opti
},
})
conn.SetIdleTimeout(idleTimeout)
fmt.Printf("mzq-test, remotecommand/websocket.go createWebSocketStreams, req: %+v, req.Body: %+v, opts: %+v, idleTime: %+v, conn:%+v\n", req, req.Body, opts, idleTimeout.String(), conn)
negotiatedProtocol, streams, err := conn.Open(responsewriter.GetOriginal(w), req)
if err != nil {
runtime.HandleError(fmt.Errorf("unable to upgrade websocket connection: %v", err))