Skip to content

Use latest k8s 1.36 - #13076

Merged
mxpv merged 2 commits into
containerd:mainfrom
SergeyKanzhelev:useLatest136
Apr 3, 2026
Merged

mxpv merged 2 commits into
containerd:mainfrom
SergeyKanzhelev:useLatest136

Conversation

@SergeyKanzhelev

@SergeyKanzhelev SergeyKanzhelev commented Mar 20, 2026 •

Copy link
Copy Markdown
Contributor

A few changes in this PR:

  1. bump to 1.36-beta.0
  2. "k8s.io/client-go/tools/remotecommand" -> k8s.io/cri-streaming/pkg/streaming/remotecommand
  3. Removed the internal/cri/streamingserver/ in favor of k8s.io/cri-streaming

/cc @dims @mikebrow @samuelkarp @chrishenzie

internal/cri/streamingserver/ diff with the new vendored folder

Diff Report: internal/cri/streamingserver vs k8s.io/cri-streaming

Generated on: Wed Apr 1 07:02:30 AM UTC 2026

Comparing internal/cri/streamingserver/errors.go

To: vendor/k8s.io/cri-streaming/pkg/streaming/errors.go

--- old_stripped.go	2026-04-01 07:02:30.899134201 +0000
+++ new_stripped.go	2026-04-01 07:02:30.902375252 +0000
@@ -1,4 +1,4 @@
-package streamingserver
+package streaming
 
 import (
 	"net/http"

Comparing internal/cri/streamingserver/portforward/constants.go

To: vendor/k8s.io/cri-streaming/pkg/streaming/portforward/constants.go

--- old_stripped.go	2026-04-01 07:02:30.918346866 +0000
+++ new_stripped.go	2026-04-01 07:02:30.921788919 +0000
@@ -5,3 +5,17 @@
 
 // SupportedProtocols are the supported port forwarding protocols.
 var SupportedProtocols = []string{ProtocolV1Name}
+
+const (
+	PortForwardV1Name                    = ProtocolV1Name
+	WebsocketsSPDYTunnelingPrefix        = "SPDY/3.1+"
+	KubernetesSuffix                     = ".k8s.io"
+	WebsocketsSPDYTunnelingPortForwardV1 = WebsocketsSPDYTunnelingPrefix + PortForwardV1Name
+
+	PortHeader                 = "port"
+	PortForwardRequestIDHeader = "requestID"
+
+	StreamType      = "streamType"
+	StreamTypeData  = "data"
+	StreamTypeError = "error"
+)

Comparing internal/cri/streamingserver/portforward/httpstream.go

To: vendor/k8s.io/cri-streaming/pkg/streaming/portforward/httpstream.go

--- old_stripped.go	2026-04-01 07:02:30.932062421 +0000
+++ new_stripped.go	2026-04-01 07:02:30.941364339 +0000
@@ -9,15 +9,14 @@
 	"sync"
 	"time"
 
-	api "github.com/containerd/containerd/v2/internal/cri/streamingserver/v1"
-	"github.com/containerd/log"
-	"k8s.io/apimachinery/pkg/types"
 	"k8s.io/streaming/pkg/httpstream"
 	"k8s.io/streaming/pkg/httpstream/spdy"
-	utilruntime "k8s.io/apimachinery/pkg/util/runtime"
+	utilruntime "k8s.io/streaming/pkg/runtime"
+
+	"k8s.io/klog/v2"
 )
 
-func handleHTTPStreams(req *http.Request, w http.ResponseWriter, portForwarder PortForwarder, podName string, uid types.UID, supportedPortForwardProtocols []string, idleTimeout, streamCreationTimeout time.Duration) error {
+func handleHTTPStreams(req *http.Request, w http.ResponseWriter, portForwarder PortForwarder, podName string, uid string, supportedPortForwardProtocols []string, idleTimeout, streamCreationTimeout time.Duration) error {
 	_, err := httpstream.Handshake(req, w, supportedPortForwardProtocols)
 	// negotiated protocol isn't currently used server side, but could be in the future
 	if err != nil {
@@ -26,7 +25,7 @@
 	}
 	streamChan := make(chan httpstream.Stream, 1)
 
-	log.L.Info("Upgrading port forward response")
+	klog.V(5).InfoS("Upgrading port forward response")
 	upgrader := spdy.NewResponseUpgrader()
 	conn := upgrader.UpgradeResponse(w, req, httpStreamReceived(streamChan))
 	if conn == nil {
@@ -34,7 +33,7 @@
 	}
 	defer conn.Close()
 
-	log.L.WithField("idleTimeout", idleTimeout).Info("Connection setting port forwarding streaming connection idle timeout")
+	klog.V(5).InfoS("Connection setting port forwarding streaming connection idle timeout", "connection", conn, "idleTimeout", idleTimeout)
 	conn.SetIdleTimeout(idleTimeout)
 
 	h := &httpStreamHandler{
@@ -58,9 +57,9 @@
 func httpStreamReceived(streams chan httpstream.Stream) func(httpstream.Stream, <-chan struct{}) error {
 	return func(stream httpstream.Stream, replySent <-chan struct{}) error {
 		// make sure it has a valid port header
-		portString := stream.Headers().Get(api.PortHeader)
+		portString := stream.Headers().Get(PortHeader)
 		if len(portString) == 0 {
-			return fmt.Errorf("%q header is required", api.PortHeader)
+			return fmt.Errorf("%q header is required", PortHeader)
 		}
 		port, err := strconv.ParseUint(portString, 10, 16)
 		if err != nil {
@@ -71,11 +70,11 @@
 		}
 
 		// make sure it has a valid stream type header
-		streamType := stream.Headers().Get(api.StreamType)
+		streamType := stream.Headers().Get(StreamType)
 		if len(streamType) == 0 {
-			return fmt.Errorf("%q header is required", api.StreamType)
+			return fmt.Errorf("%q header is required", StreamType)
 		}
-		if streamType != api.StreamTypeError && streamType != api.StreamTypeData {
+		if streamType != StreamTypeError && streamType != StreamTypeData {
 			return fmt.Errorf("invalid stream type %q", streamType)
 		}
 
@@ -93,7 +92,7 @@
 	streamPairs           map[string]*httpStreamPair
 	streamCreationTimeout time.Duration
 	pod                   string
-	uid                   types.UID
+	uid                   string
 	forwarder             PortForwarder
 }
 
@@ -105,11 +104,11 @@
 	defer h.streamPairsLock.Unlock()
 
 	if p, ok := h.streamPairs[requestID]; ok {
-		log.L.WithField("requestID", requestID).Info("Connection request found existing stream pair connection")
+		klog.V(5).InfoS("Connection request found existing stream pair", "connection", h.conn, "request", requestID)
 		return p, false
 	}
 
-	log.L.WithField("requestID", requestID).Info("Connection request creating new stream pair connection")
+	klog.V(5).InfoS("Connection request creating new stream pair", "connection", h.conn, "request", requestID)
 
 	p := newPortForwardPair(requestID)
 	h.streamPairs[requestID] = p
@@ -127,7 +126,7 @@
 		utilruntime.HandleError(err)
 		p.printError(err.Error())
 	case <-p.complete:
-		log.L.WithField("requestID", p.requestID).Info("Connection request successfully received error and data streams connection")
+		klog.V(5).InfoS("Connection request successfully received error and data streams", "connection", h.conn, "request", p.requestID)
 	}
 	h.removeStreamPair(p.requestID)
 }
@@ -156,9 +155,9 @@
 
 // requestID returns the request id for stream.
 func (h *httpStreamHandler) requestID(stream httpstream.Stream) string {
-	requestID := stream.Headers().Get(api.PortForwardRequestIDHeader)
+	requestID := stream.Headers().Get(PortForwardRequestIDHeader)
 	if len(requestID) == 0 {
-		log.L.Info("Connection stream received without requestID header connection")
+		klog.V(5).InfoS("Connection stream received without requestID header", "connection", h.conn)
 		// If we get here, it's because the connection came from an older client
 		// that isn't generating the request id header
 		// (https://github.com/kubernetes/kubernetes/blob/843134885e7e0b360eb5441e85b1410a8b1a7a0c/pkg/client/unversioned/portforward/portforward.go#L258-L287)
@@ -177,16 +176,15 @@
 		// old clients that don't generate request ids.  If there are concurrent
 		// new connections, it's possible that 1 connection gets streams whose IDs
 		// are not consecutive (e.g. 5 and 9 instead of 5 and 7).
-		streamType := stream.Headers().Get(api.StreamType)
+		streamType := stream.Headers().Get(StreamType)
 		switch streamType {
-		case api.StreamTypeError:
+		case StreamTypeError:
 			requestID = strconv.Itoa(int(stream.Identifier()))
-		case api.StreamTypeData:
+		case StreamTypeData:
 			requestID = strconv.Itoa(int(stream.Identifier()) - 2)
 		}
 
-		log.L.WithFields(log.Fields{"request": requestID, "streamType": streamType, "stream": stream.Identifier()}).Infof(
-			"Connection automatically assigning request ID from stream type and stream ID connection")
+		klog.V(5).InfoS("Connection automatically assigning request ID from stream type and stream ID", "connection", h.conn, "request", requestID, "streamType", streamType, "stream", stream.Identifier())
 	}
 	return requestID
 }
@@ -195,18 +193,17 @@
 // streams, invoking portForward for each complete stream pair. The loop exits
 // when the httpstream.Connection is closed.
 func (h *httpStreamHandler) run() {
-	log.L.Info("Connection waiting for port forward streams connection")
+	klog.V(5).InfoS("Connection waiting for port forward streams", "connection", h.conn)
 Loop:
 	for {
 		select {
 		case <-h.conn.CloseChan():
-			log.L.Info("Connection upgraded connection closed connection")
+			klog.V(5).InfoS("Connection upgraded connection closed", "connection", h.conn)
 			break Loop
 		case stream := <-h.streamChan:
 			requestID := h.requestID(stream)
-			streamType := stream.Headers().Get(api.StreamType)
-			log.L.WithFields(log.Fields{"request": requestID, "streamType": streamType}).Info(
-				"Connection request received new type of stream connection")
+			streamType := stream.Headers().Get(StreamType)
+			klog.V(5).InfoS("Connection request received new type of stream", "connection", h.conn, "request", requestID, "streamType", streamType)
 
 			p, created := h.getStreamPair(requestID)
 			if created {
@@ -230,14 +227,12 @@
 	defer p.dataStream.Close()
 	defer p.errorStream.Close()
 
-	portString := p.dataStream.Headers().Get(api.PortHeader)
+	portString := p.dataStream.Headers().Get(PortHeader)
 	port, _ := strconv.ParseInt(portString, 10, 32)
 
-	log.L.WithFields(log.Fields{"request": p.requestID, "port": portString}).Info(
-		"Connection request invoking forwarder.PortForward for port connection")
+	klog.V(5).InfoS("Connection request invoking forwarder.PortForward for port", "connection", h.conn, "request", p.requestID, "port", portString)
 	err := h.forwarder.PortForward(ctx, h.pod, h.uid, int32(port), p.dataStream)
-	log.L.WithFields(log.Fields{"request": p.requestID, "port": portString}).Info(
-		"Connection request done invoking forwarder.PortForward for port connection")
+	klog.V(5).InfoS("Connection request done invoking forwarder.PortForward for port", "connection", h.conn, "request", p.requestID, "port", portString)
 
 	if err != nil {
 		msg := fmt.Errorf("error forwarding port %d to pod %s, uid %v: %v", port, h.pod, h.uid, err)
@@ -247,8 +242,8 @@
 		// with data stream most probably, thus we want to reset the streams
 		// indicating there was a problem and allow a new set of streams be
 		// created to mitigate the problem
-		p.dataStream.Reset()  //nolint:errcheck
-		p.errorStream.Reset() //nolint:errcheck
+		p.dataStream.Reset()  // nolint:errcheck
+		p.errorStream.Reset() // nolint:errcheck
 	}
 }
 
@@ -278,13 +273,13 @@
 	p.lock.Lock()
 	defer p.lock.Unlock()
 
-	switch stream.Headers().Get(api.StreamType) {
-	case api.StreamTypeError:
+	switch stream.Headers().Get(StreamType) {
+	case StreamTypeError:
 		if p.errorStream != nil {
 			return false, errors.New("error stream already assigned")
 		}
 		p.errorStream = stream
-	case api.StreamTypeData:
+	case StreamTypeData:
 		if p.dataStream != nil {
 			return false, errors.New("data stream already assigned")
 		}

Comparing internal/cri/streamingserver/portforward/portforward.go

To: vendor/k8s.io/cri-streaming/pkg/streaming/portforward/portforward.go

--- old_stripped.go	2026-04-01 07:02:30.952064078 +0000
+++ new_stripped.go	2026-04-01 07:02:30.959198866 +0000
@@ -6,16 +6,15 @@
 	"net/http"
 	"time"
 
-	"k8s.io/apimachinery/pkg/types"
 	"k8s.io/streaming/pkg/httpstream/wsstream"
-	"k8s.io/apimachinery/pkg/util/runtime"
+	"k8s.io/streaming/pkg/runtime"
 )
 
 // PortForwarder knows how to forward content from a data stream to/from a port
 // in a pod.
 type PortForwarder interface {
 	// PortForwarder copies data between a data stream and a port in a pod.
-	PortForward(ctx context.Context, name string, uid types.UID, port int32, stream io.ReadWriteCloser) error
+	PortForward(ctx context.Context, name string, uid string, port int32, stream io.ReadWriteCloser) error
 }
 
 // ServePortForward handles a port forwarding request.  A single request is
@@ -23,7 +22,7 @@
 // been timed out due to idleness. This function handles multiple forwarded
 // connections; i.e., multiple `curl http://localhost:8888/` requests will be
 // handled by a single invocation of ServePortForward.
-func ServePortForward(w http.ResponseWriter, req *http.Request, portForwarder PortForwarder, podName string, uid types.UID, portForwardOptions *V4Options, idleTimeout time.Duration, streamCreationTimeout time.Duration, supportedProtocols []string) {
+func ServePortForward(w http.ResponseWriter, req *http.Request, portForwarder PortForwarder, podName string, uid string, portForwardOptions *V4Options, idleTimeout time.Duration, streamCreationTimeout time.Duration, supportedProtocols []string) {
 	var err error
 	if wsstream.IsWebSocketRequest(req) {
 		err = handleWebSocketStreams(req, w, portForwarder, podName, uid, portForwardOptions, supportedProtocols, idleTimeout, streamCreationTimeout)

Comparing internal/cri/streamingserver/portforward/websocket.go

To: vendor/k8s.io/cri-streaming/pkg/streaming/portforward/websocket.go

--- old_stripped.go	2026-04-01 07:02:30.968065404 +0000
+++ new_stripped.go	2026-04-01 07:02:30.972065735 +0000
@@ -11,12 +11,11 @@
 	"sync"
 	"time"
 
-	"github.com/containerd/containerd/v2/internal/cri/streamingserver/responsewriter"
-	api "github.com/containerd/containerd/v2/internal/cri/streamingserver/v1"
-	"github.com/containerd/log"
-	"k8s.io/apimachinery/pkg/types"
+	"k8s.io/klog/v2"
+
+	"k8s.io/cri-streaming/pkg/streaming/internal/httpresponse"
 	"k8s.io/streaming/pkg/httpstream/wsstream"
-	"k8s.io/apimachinery/pkg/util/runtime"
+	"k8s.io/streaming/pkg/runtime"
 )
 
 const (
@@ -41,17 +40,17 @@
 		return &V4Options{}, nil
 	}
 
-	portStrings := req.URL.Query()[api.PortHeader]
+	portStrings := req.URL.Query()[PortHeader]
 	if len(portStrings) == 0 {
-		return nil, fmt.Errorf("query parameter %q is required", api.PortHeader)
+		return nil, fmt.Errorf("query parameter %q is required", PortHeader)
 	}
 
 	ports := make([]int32, 0, len(portStrings))
 	for _, portString := range portStrings {
 		if len(portString) == 0 {
-			return nil, fmt.Errorf("query parameter %q cannot be empty", api.PortHeader)
+			return nil, fmt.Errorf("query parameter %q cannot be empty", PortHeader)
 		}
-		for p := range strings.SplitSeq(portString, ",") {
+		for _, p := range strings.Split(portString, ",") {
 			port, err := strconv.ParseUint(p, 10, 16)
 			if err != nil {
 				return nil, fmt.Errorf("unable to parse %q as a port: %v", portString, err)
@@ -77,7 +76,7 @@
 // a PortForwarder. A pair of streams are created per port (DATA n,
 // ERROR n+1). The associated port is written to each stream as a unsigned 16
 // bit integer in little endian format.
-func handleWebSocketStreams(req *http.Request, w http.ResponseWriter, portForwarder PortForwarder, podName string, uid types.UID, opts *V4Options, supportedPortForwardProtocols []string, idleTimeout, streamCreationTimeout time.Duration) error {
+func handleWebSocketStreams(req *http.Request, w http.ResponseWriter, portForwarder PortForwarder, podName string, uid string, opts *V4Options, supportedPortForwardProtocols []string, idleTimeout, streamCreationTimeout time.Duration) error {
 	channels := make([]wsstream.ChannelType, 0, len(opts.Ports)*2)
 	for i := 0; i < len(opts.Ports); i++ {
 		channels = append(channels, wsstream.ReadWriteChannel, wsstream.WriteChannel)
@@ -97,7 +96,7 @@
 		},
 	})
 	conn.SetIdleTimeout(idleTimeout)
-	_, streams, err := conn.Open(responsewriter.GetOriginal(w), req)
+	_, streams, err := conn.Open(httpresponse.GetOriginal(w), req)
 	if err != nil {
 		err = fmt.Errorf("unable to upgrade websocket connection: %v", err)
 		return err
@@ -144,7 +143,7 @@
 	conn        *wsstream.Conn
 	streamPairs []*websocketStreamPair
 	pod         string
-	uid         types.UID
+	uid         string
 	forwarder   PortForwarder
 }
 
@@ -170,9 +169,9 @@
 	defer p.dataStream.Close()
 	defer p.errorStream.Close()
 
-	log.L.WithField("port", p.port).Info("Connection invoking forwarder.PortForward for port connection")
+	klog.V(5).InfoS("Connection invoking forwarder.PortForward for port", "connection", h.conn, "port", p.port)
 	err := h.forwarder.PortForward(ctx, h.pod, h.uid, p.port, p.dataStream)
-	log.L.WithField("port", p.port).Info("Connection done invoking forwarder.PortForward for port connection")
+	klog.V(5).InfoS("Connection done invoking forwarder.PortForward for port", "connection", h.conn, "port", p.port)
 
 	if err != nil {
 		msg := fmt.Errorf("error forwarding port %d to pod %s, uid %v: %v", p.port, h.pod, h.uid, err)

Comparing internal/cri/streamingserver/remotecommand/attach.go

To: vendor/k8s.io/cri-streaming/pkg/streaming/remotecommand/attach.go

--- old_stripped.go	2026-04-01 07:02:30.991296032 +0000
+++ new_stripped.go	2026-04-01 07:02:30.994524806 +0000
@@ -7,23 +7,19 @@
 	"net/http"
 	"time"
 
-	apierrors "k8s.io/apimachinery/pkg/api/errors"
-	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-	"k8s.io/apimachinery/pkg/types"
-	"k8s.io/apimachinery/pkg/util/runtime"
-	"k8s.io/client-go/tools/remotecommand"
+	"k8s.io/streaming/pkg/runtime"
 )
 
 // Attacher knows how to attach to a running container in a pod.
 type Attacher interface {
 	// AttachContainer attaches to the running container in the pod, copying data between in/out/err
 	// and the container's stdin/stdout/stderr.
-	AttachContainer(ctx context.Context, name string, uid types.UID, container string, in io.Reader, out, err io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize) error
+	AttachContainer(ctx context.Context, name string, uid string, container string, in io.Reader, out, err io.WriteCloser, tty bool, resize <-chan TerminalSize) error
 }
 
 // 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) {
+func ServeAttach(w http.ResponseWriter, req *http.Request, attacher Attacher, podName string, uid string, container string, streamOpts *Options, idleTimeout, streamCreationTimeout time.Duration, supportedProtocols []string) {
 	ctx, ok := createStreams(req, w, streamOpts, supportedProtocols, idleTimeout, streamCreationTimeout)
 	if !ok {
 		// error is handled by createStreams
@@ -35,10 +31,10 @@
 	if err != nil {
 		err = fmt.Errorf("error attaching to container: %v", err)
 		runtime.HandleError(err)
-		ctx.writeStatus(apierrors.NewInternalError(err))
+		ctx.writeStatus(newInternalError(err))
 	} else {
-		ctx.writeStatus(&apierrors.StatusError{ErrStatus: metav1.Status{
-			Status: metav1.StatusSuccess,
+		ctx.writeStatus(&streamStatusError{ErrStatus: streamStatus{
+			Status: statusSuccess,
 		}})
 	}
 }

Comparing internal/cri/streamingserver/remotecommand/exec.go

To: vendor/k8s.io/cri-streaming/pkg/streaming/remotecommand/exec.go

--- old_stripped.go	2026-04-01 07:02:31.010678490 +0000
+++ new_stripped.go	2026-04-01 07:02:31.013683399 +0000
@@ -7,26 +7,21 @@
 	"net/http"
 	"time"
 
-	utilexec "github.com/containerd/containerd/v2/internal/cri/executil"
-	apierrors "k8s.io/apimachinery/pkg/api/errors"
-	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-	"k8s.io/apimachinery/pkg/types"
-	remotecommandconsts "k8s.io/apimachinery/pkg/util/remotecommand"
-	"k8s.io/apimachinery/pkg/util/runtime"
-	"k8s.io/client-go/tools/remotecommand"
+	"k8s.io/streaming/pkg/runtime"
+	utilexec "k8s.io/utils/exec"
 )
 
 // Executor knows how to execute a command in a container in a pod.
 type Executor interface {
 	// ExecInContainer executes a command in a container in the pod, copying data
 	// between in/out/err and the container's stdin/stdout/stderr.
-	ExecInContainer(ctx context.Context, name string, uid types.UID, container string, cmd []string, in io.Reader, out, err io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize, timeout time.Duration) error
+	ExecInContainer(ctx context.Context, name string, uid string, container string, cmd []string, in io.Reader, out, err io.WriteCloser, tty bool, resize <-chan TerminalSize, timeout time.Duration) error
 }
 
 // ServeExec handles requests to execute a command in a container. After
 // 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) {
+func ServeExec(w http.ResponseWriter, req *http.Request, executor Executor, podName string, uid string, container string, cmd []string, streamOpts *Options, idleTimeout, streamCreationTimeout time.Duration, supportedProtocols []string) {
 	ctx, ok := createStreams(req, w, streamOpts, supportedProtocols, idleTimeout, streamCreationTimeout)
 	if !ok {
 		// error is handled by createStreams
@@ -38,13 +33,13 @@
 	if err != nil {
 		if exitErr, ok := err.(utilexec.ExitError); ok && exitErr.Exited() {
 			rc := exitErr.ExitStatus()
-			ctx.writeStatus(&apierrors.StatusError{ErrStatus: metav1.Status{
-				Status: metav1.StatusFailure,
-				Reason: remotecommandconsts.NonZeroExitCodeReason,
-				Details: &metav1.StatusDetails{
-					Causes: []metav1.StatusCause{
+			ctx.writeStatus(&streamStatusError{ErrStatus: streamStatus{
+				Status: statusFailure,
+				Reason: NonZeroExitCodeReason,
+				Details: &streamStatusDetails{
+					Causes: []streamStatusCause{
 						{
-							Type:    remotecommandconsts.ExitCodeCauseType,
+							Type:    ExitCodeCauseType,
 							Message: fmt.Sprintf("%d", rc),
 						},
 					},
@@ -54,11 +49,11 @@
 		} else {
 			err = fmt.Errorf("error executing command in container: %v", err)
 			runtime.HandleError(err)
-			ctx.writeStatus(apierrors.NewInternalError(err))
+			ctx.writeStatus(newInternalError(err))
 		}
 	} else {
-		ctx.writeStatus(&apierrors.StatusError{ErrStatus: metav1.Status{
-			Status: metav1.StatusSuccess,
+		ctx.writeStatus(&streamStatusError{ErrStatus: streamStatus{
+			Status: statusSuccess,
 		}})
 	}
 }

Comparing internal/cri/streamingserver/remotecommand/httpstream.go

To: vendor/k8s.io/cri-streaming/pkg/streaming/remotecommand/httpstream.go

--- old_stripped.go	2026-04-01 07:02:31.024070045 +0000
+++ new_stripped.go	2026-04-01 07:02:31.031947933 +0000
@@ -9,16 +9,12 @@
 	"net/http"
 	"time"
 
-	api "github.com/containerd/containerd/v2/internal/cri/streamingserver/v1"
-	"github.com/containerd/log"
-	apierrors "k8s.io/apimachinery/pkg/api/errors"
-	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/streaming/pkg/httpstream"
 	"k8s.io/streaming/pkg/httpstream/spdy"
 	"k8s.io/streaming/pkg/httpstream/wsstream"
-	remotecommandconsts "k8s.io/apimachinery/pkg/util/remotecommand"
-	"k8s.io/apimachinery/pkg/util/runtime"
-	"k8s.io/client-go/tools/remotecommand"
+	"k8s.io/streaming/pkg/runtime"
+
+	"k8s.io/klog/v2"
 )
 
 // Options contains details about which streams are required for
@@ -32,13 +28,13 @@
 
 // NewOptions creates a new Options from the Request.
 func NewOptions(req *http.Request) (*Options, error) {
-	tty := req.FormValue(api.ExecTTYParam) == "1"
-	stdin := req.FormValue(api.ExecStdinParam) == "1"
-	stdout := req.FormValue(api.ExecStdoutParam) == "1"
-	stderr := req.FormValue(api.ExecStderrParam) == "1"
+	tty := req.FormValue(ExecTTYParam) == "1"
+	stdin := req.FormValue(ExecStdinParam) == "1"
+	stdout := req.FormValue(ExecStdoutParam) == "1"
+	stderr := req.FormValue(ExecStderrParam) == "1"
 	if tty && stderr {
 		// TODO: make this an error before we reach this method
-		log.L.Info("Access to exec with tty and stderr is not supported, bypassing stderr")
+		klog.V(4).InfoS("Access to exec with tty and stderr is not supported, bypassing stderr")
 		stderr = false
 	}
 
@@ -61,9 +57,9 @@
 	stdinStream  io.ReadCloser
 	stdoutStream io.WriteCloser
 	stderrStream io.WriteCloser
-	writeStatus  func(status *apierrors.StatusError) error
+	writeStatus  func(status *streamStatusError) error
 	resizeStream io.ReadCloser
-	resizeChan   chan remotecommand.TerminalSize
+	resizeChan   chan TerminalSize
 	tty          bool
 }
 
@@ -99,7 +95,7 @@
 	}
 
 	if ctx.resizeStream != nil {
-		ctx.resizeChan = make(chan remotecommand.TerminalSize)
+		ctx.resizeChan = make(chan TerminalSize)
 		go handleResizeEvents(req.Context(), ctx.resizeStream, ctx.resizeChan)
 	}
 
@@ -109,7 +105,7 @@
 func createHTTPStreamStreams(req *http.Request, w http.ResponseWriter, opts *Options, supportedStreamProtocols []string, idleTimeout, streamCreationTimeout time.Duration) (*connectionContext, bool) {
 	protocol, err := httpstream.Handshake(req, w, supportedStreamProtocols)
 	if err != nil {
-		http.Error(w, err.Error(), http.StatusBadRequest)
+		// Handshake writes the error to the client
 		return nil, false
 	}
 
@@ -132,16 +128,16 @@
 
 	var handler protocolHandler
 	switch protocol {
-	case remotecommandconsts.StreamProtocolV4Name:
+	case StreamProtocolV4Name:
 		handler = &v4ProtocolHandler{}
-	case remotecommandconsts.StreamProtocolV3Name:
+	case StreamProtocolV3Name:
 		handler = &v3ProtocolHandler{}
-	case remotecommandconsts.StreamProtocolV2Name:
+	case StreamProtocolV2Name:
 		handler = &v2ProtocolHandler{}
 	case "":
-		log.L.WithField("protocol", remotecommandconsts.StreamProtocolV1Name).Info("Client did not request protocol negotiation. Falling back")
+		klog.V(4).InfoS("Client did not request protocol negotiation. Falling back", "protocol", StreamProtocolV1Name)
 		fallthrough
-	case remotecommandconsts.StreamProtocolV1Name:
+	case StreamProtocolV1Name:
 		handler = &v1ProtocolHandler{}
 	}
 
@@ -184,7 +180,7 @@
 }
 
 // v4ProtocolHandler implements the V4 protocol version for streaming command execution. It only differs
-// in from v3 in the error stream format using an json-marshaled metav1.Status which carries
+// in from v3 in the error stream format using a json-marshaled status object which carries
 // the process' exit code.
 type v4ProtocolHandler struct{}
 
@@ -198,21 +194,21 @@
 	for {
 		select {
 		case stream := <-streams:
-			streamType := stream.Headers().Get(api.StreamType)
+			streamType := stream.Headers().Get(StreamType)
 			switch streamType {
-			case api.StreamTypeError:
+			case StreamTypeError:
 				ctx.writeStatus = v4WriteStatusFunc(stream) // write json errors
 				go waitStreamReply(stream.replySent, replyChan, stop)
-			case api.StreamTypeStdin:
+			case StreamTypeStdin:
 				ctx.stdinStream = stream
 				go waitStreamReply(stream.replySent, replyChan, stop)
-			case api.StreamTypeStdout:
+			case StreamTypeStdout:
 				ctx.stdoutStream = stream
 				go waitStreamReply(stream.replySent, replyChan, stop)
-			case api.StreamTypeStderr:
+			case StreamTypeStderr:
 				ctx.stderrStream = stream
 				go waitStreamReply(stream.replySent, replyChan, stop)
-			case api.StreamTypeResize:
+			case StreamTypeResize:
 				ctx.resizeStream = stream
 				go waitStreamReply(stream.replySent, replyChan, stop)
 			default:
@@ -249,21 +245,21 @@
 	for {
 		select {
 		case stream := <-streams:
-			streamType := stream.Headers().Get(api.StreamType)
+			streamType := stream.Headers().Get(StreamType)
 			switch streamType {
-			case api.StreamTypeError:
+			case StreamTypeError:
 				ctx.writeStatus = v1WriteStatusFunc(stream)
 				go waitStreamReply(stream.replySent, replyChan, stop)
-			case api.StreamTypeStdin:
+			case StreamTypeStdin:
 				ctx.stdinStream = stream
 				go waitStreamReply(stream.replySent, replyChan, stop)
-			case api.StreamTypeStdout:
+			case StreamTypeStdout:
 				ctx.stdoutStream = stream
 				go waitStreamReply(stream.replySent, replyChan, stop)
-			case api.StreamTypeStderr:
+			case StreamTypeStderr:
 				ctx.stderrStream = stream
 				go waitStreamReply(stream.replySent, replyChan, stop)
-			case api.StreamTypeResize:
+			case StreamTypeResize:
 				ctx.resizeStream = stream
 				go waitStreamReply(stream.replySent, replyChan, stop)
 			default:
@@ -300,18 +296,18 @@
 	for {
 		select {
 		case stream := <-streams:
-			streamType := stream.Headers().Get(api.StreamType)
+			streamType := stream.Headers().Get(StreamType)
 			switch streamType {
-			case api.StreamTypeError:
+			case StreamTypeError:
 				ctx.writeStatus = v1WriteStatusFunc(stream)
 				go waitStreamReply(stream.replySent, replyChan, stop)
-			case api.StreamTypeStdin:
+			case StreamTypeStdin:
 				ctx.stdinStream = stream
 				go waitStreamReply(stream.replySent, replyChan, stop)
-			case api.StreamTypeStdout:
+			case StreamTypeStdout:
 				ctx.stdoutStream = stream
 				go waitStreamReply(stream.replySent, replyChan, stop)
-			case api.StreamTypeStderr:
+			case StreamTypeStderr:
 				ctx.stderrStream = stream
 				go waitStreamReply(stream.replySent, replyChan, stop)
 			default:
@@ -348,9 +344,9 @@
 	for {
 		select {
 		case stream := <-streams:
-			streamType := stream.Headers().Get(api.StreamType)
+			streamType := stream.Headers().Get(StreamType)
 			switch streamType {
-			case api.StreamTypeError:
+			case StreamTypeError:
 				ctx.writeStatus = v1WriteStatusFunc(stream)
 
 				// This defer statement shouldn't be here, but due to previous refactoring, it ended up in
@@ -359,13 +355,13 @@
 				defer stream.Reset()
 
 				go waitStreamReply(stream.replySent, replyChan, stop)
-			case api.StreamTypeStdin:
+			case StreamTypeStdin:
 				ctx.stdinStream = stream
 				go waitStreamReply(stream.replySent, replyChan, stop)
-			case api.StreamTypeStdout:
+			case StreamTypeStdout:
 				ctx.stdoutStream = stream
 				go waitStreamReply(stream.replySent, replyChan, stop)
-			case api.StreamTypeStderr:
+			case StreamTypeStderr:
 				ctx.stderrStream = stream
 				go waitStreamReply(stream.replySent, replyChan, stop)
 			default:
@@ -393,13 +389,13 @@
 // supportsTerminalResizing returns false because v1ProtocolHandler doesn't support it.
 func (*v1ProtocolHandler) supportsTerminalResizing() bool { return false }
 
-func handleResizeEvents(reqctx context.Context, stream io.Reader, channel chan<- remotecommand.TerminalSize) {
+func handleResizeEvents(reqctx context.Context, stream io.Reader, channel chan<- TerminalSize) {
 	defer runtime.HandleCrash()
 	defer close(channel)
 
 	decoder := json.NewDecoder(stream)
 	for {
-		size := remotecommand.TerminalSize{}
+		size := TerminalSize{}
 		if err := decoder.Decode(&size); err != nil {
 			break
 		}
@@ -412,9 +408,9 @@
 	}
 }
 
-func v1WriteStatusFunc(stream io.Writer) func(status *apierrors.StatusError) error {
-	return func(status *apierrors.StatusError) error {
-		if status.Status().Status == metav1.StatusSuccess {
+func v1WriteStatusFunc(stream io.Writer) func(status *streamStatusError) error {
+	return func(status *streamStatusError) error {
+		if status.status().Status == statusSuccess {
 			return nil // send error messages
 		}
 		_, err := stream.Write([]byte(status.Error()))
@@ -422,11 +418,11 @@
 	}
 }
 
-// v4WriteStatusFunc returns a WriteStatusFunc that marshals a given api Status
+// v4WriteStatusFunc returns a WriteStatusFunc that marshals a status object
 // as json in the error channel.
-func v4WriteStatusFunc(stream io.Writer) func(status *apierrors.StatusError) error {
-	return func(status *apierrors.StatusError) error {
-		bs, err := json.Marshal(status.Status())
+func v4WriteStatusFunc(stream io.Writer) func(status *streamStatusError) error {
+	return func(status *streamStatusError) error {
+		bs, err := json.Marshal(status.status())
 		if err != nil {
 			return err
 		}

Comparing internal/cri/streamingserver/remotecommand/websocket.go

To: vendor/k8s.io/cri-streaming/pkg/streaming/remotecommand/websocket.go

--- old_stripped.go	2026-04-01 07:02:31.047229184 +0000
+++ new_stripped.go	2026-04-01 07:02:31.050190072 +0000
@@ -5,9 +5,9 @@
 	"net/http"
 	"time"
 
-	"github.com/containerd/containerd/v2/internal/cri/streamingserver/responsewriter"
+	"k8s.io/cri-streaming/pkg/streaming/internal/httpresponse"
 	"k8s.io/streaming/pkg/httpstream/wsstream"
-	"k8s.io/apimachinery/pkg/util/runtime"
+	"k8s.io/streaming/pkg/runtime"
 )
 
 const (
@@ -79,7 +79,7 @@
 		},
 	})
 	conn.SetIdleTimeout(idleTimeout)
-	negotiatedProtocol, streams, err := conn.Open(responsewriter.GetOriginal(w), req)
+	negotiatedProtocol, streams, err := conn.Open(httpresponse.GetOriginal(w), req)
 	if err != nil {
 		runtime.HandleError(fmt.Errorf("unable to upgrade websocket connection: %v", err))
 		return nil, false

Comparing internal/cri/streamingserver/request_cache.go

To: vendor/k8s.io/cri-streaming/pkg/streaming/request_cache.go

--- old_stripped.go	2026-04-01 07:02:31.060073028 +0000
+++ new_stripped.go	2026-04-01 07:02:31.064073359 +0000
@@ -1,4 +1,4 @@
-package streamingserver
+package streaming
 
 import (
 	"container/list"
@@ -9,7 +9,7 @@
 	"sync"
 	"time"
 
-	"github.com/containerd/containerd/v2/internal/cri/clock"
+	"k8s.io/utils/clock"
 )
 
 var (
@@ -37,7 +37,7 @@
 }
 
 // Type representing an *ExecRequest, *AttachRequest, or *PortForwardRequest.
-type request any
+type request interface{}
 
 type cacheEntry struct {
 	token      string `datapolicy:"token"`
@@ -99,7 +99,7 @@
 	// Number of bytes to be tokenLen when base64 encoded.
 	tokenSize := math.Ceil(float64(tokenLen) * 6 / 8)
 	rawToken := make([]byte, int(tokenSize))
-	for range maxTries {
+	for i := 0; i < maxTries; i++ {
 		if _, err := rand.Read(rawToken); err != nil {
 			return "", err
 		}

Comparing internal/cri/streamingserver/server.go

To: vendor/k8s.io/cri-streaming/pkg/streaming/server.go

--- old_stripped.go	2026-04-01 07:02:31.082662166 +0000
+++ new_stripped.go	2026-04-01 07:02:31.086314913 +0000
@@ -1,4 +1,4 @@
-package streamingserver
+package streaming
 
 import (
 	"context"
@@ -16,12 +16,9 @@
 
 	restful "github.com/emicklei/go-restful/v3"
 
-	"github.com/containerd/containerd/v2/internal/cri/streamingserver/portforward"
-	remotecommandserver "github.com/containerd/containerd/v2/internal/cri/streamingserver/remotecommand"
-	"k8s.io/apimachinery/pkg/types"
-	remotecommandconsts "k8s.io/apimachinery/pkg/util/remotecommand"
-	"k8s.io/client-go/tools/remotecommand"
 	runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
+	"k8s.io/cri-streaming/pkg/streaming/portforward"
+	remotecommandserver "k8s.io/cri-streaming/pkg/streaming/remotecommand"
 )
 
 // Server is the library interface to serve the stream requests.
@@ -46,8 +43,8 @@
 
 // Runtime is the interface to execute the commands and provide the streams.
 type Runtime interface {
-	Exec(ctx context.Context, containerID string, cmd []string, in io.Reader, out, err io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize) error
-	Attach(ctx context.Context, containerID string, in io.Reader, out, err io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize) error
+	Exec(ctx context.Context, containerID string, cmd []string, in io.Reader, out, err io.WriteCloser, tty bool, resize <-chan remotecommandserver.TerminalSize) error
+	Attach(ctx context.Context, containerID string, in io.Reader, out, err io.WriteCloser, tty bool, resize <-chan remotecommandserver.TerminalSize) error
 	PortForward(ctx context.Context, podSandboxID string, port int32, stream io.ReadWriteCloser) error
 }
 
@@ -83,8 +80,8 @@
 // some fields like Addr must still be provided.
 var DefaultConfig = Config{
 	StreamIdleTimeout:               4 * time.Hour,
-	StreamCreationTimeout:           remotecommandconsts.DefaultStreamCreationTimeout,
-	SupportedRemoteCommandProtocols: remotecommandconsts.SupportedStreamingProtocols,
+	StreamCreationTimeout:           remotecommandserver.DefaultStreamCreationTimeout,
+	SupportedRemoteCommandProtocols: remotecommandserver.SupportedStreamingProtocols,
 	SupportedPortForwardProtocols:   portforward.SupportedProtocols,
 }
 
@@ -130,10 +127,9 @@
 	handler.Add(ws)
 	s.handler = handler
 	s.server = &http.Server{
-		Addr:              s.config.Addr,
-		Handler:           s.handler,
-		TLSConfig:         s.config.TLSConfig,
-		ReadHeaderTimeout: 0,
+		Addr:      s.config.Addr,
+		Handler:   s.handler,
+		TLSConfig: s.config.TLSConfig,
 	}
 
 	return s, nil
@@ -355,14 +351,14 @@
 var _ remotecommandserver.Attacher = &criAdapter{}
 var _ portforward.PortForwarder = &criAdapter{}
 
-func (a *criAdapter) ExecInContainer(ctx context.Context, podName string, podUID types.UID, container string, cmd []string, in io.Reader, out, err io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize, timeout time.Duration) error {
+func (a *criAdapter) ExecInContainer(ctx context.Context, podName string, podUID string, container string, cmd []string, in io.Reader, out, err io.WriteCloser, tty bool, resize <-chan remotecommandserver.TerminalSize, timeout time.Duration) error {
 	return a.Runtime.Exec(ctx, container, cmd, in, out, err, tty, resize)
 }
 
-func (a *criAdapter) AttachContainer(ctx context.Context, podName string, podUID types.UID, container string, in io.Reader, out, err io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize) error {
+func (a *criAdapter) AttachContainer(ctx context.Context, podName string, podUID string, container string, in io.Reader, out, err io.WriteCloser, tty bool, resize <-chan remotecommandserver.TerminalSize) error {
 	return a.Runtime.Attach(ctx, container, in, out, err, tty, resize)
 }
 
-func (a *criAdapter) PortForward(ctx context.Context, podName string, podUID types.UID, port int32, stream io.ReadWriteCloser) error {
+func (a *criAdapter) PortForward(ctx context.Context, podName string, podUID string, port int32, stream io.ReadWriteCloser) error {
 	return a.Runtime.PortForward(ctx, podName, port, stream)
 }

@github-project-automation github-project-automation Bot moved this to Needs Triage in Pull Request Review Mar 20, 2026
@k8s-ci-robot
k8s-ci-robot requested review from dims and mikebrow March 20, 2026 18:19
@dosubot dosubot Bot added area/cri Container Runtime Interface (CRI) dependencies Pull requests that update a dependency file labels Mar 20, 2026
@SergeyKanzhelev

Copy link
Copy Markdown
Contributor Author

So all the certificate generation logic for streamign server is still in k8s.io/client-go

@mikebrow

Copy link
Copy Markdown
Member

:-)

@samuelkarp

Copy link
Copy Markdown
Member

FAIL - does not have a valid DCO

Please sign-off your commit.

@SergeyKanzhelev
SergeyKanzhelev force-pushed the useLatest136 branch 5 times, most recently from f1772a7 to 647a77f Compare March 22, 2026 22:36
This was referenced Mar 22, 2026
@SergeyKanzhelev SergeyKanzhelev changed the title [WIP] Use latest136 Use latest k8s 1.36 Apr 1, 2026
@SergeyKanzhelev

Copy link
Copy Markdown
Contributor Author

/retest

1 similar comment
@SergeyKanzhelev

Copy link
Copy Markdown
Contributor Author

/retest

@SergeyKanzhelev

Copy link
Copy Markdown
Contributor Author

btw, @mikebrow do you know whether contextual logging was initialized by containerd for some other dependent k8s libraries before? Or this needs to be looked at?

@SergeyKanzhelev

Copy link
Copy Markdown
Contributor Author

@samuelkarp @mikebrow this passes tests now. Please take a look

@github-project-automation github-project-automation Bot moved this from Needs Triage to Review In Progress in Pull Request Review Apr 3, 2026
@mxpv
mxpv added this pull request to the merge queue Apr 3, 2026
Merged via the queue into containerd:main with commit 6c88546 Apr 3, 2026
54 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Apr 3, 2026
@SergeyKanzhelev
SergeyKanzhelev deleted the useLatest136 branch April 3, 2026 15:54
Comment thread go.mod
github.com/containernetworking/plugins v1.9.1
github.com/coreos/go-systemd/v22 v22.7.0
github.com/davecgh/go-spew v1.1.1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc

@thaJeztah thaJeztah Apr 21, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come we're back at unreleased (and for this one: never to be released) versions?

go mod graph | grep ' github.com/davecgh/[email protected]'
github.com/containerd/containerd/v2 github.com/davecgh/[email protected]
k8s.io/[email protected] github.com/davecgh/[email protected]
k8s.io/[email protected] github.com/davecgh/[email protected]
k8s.io/[email protected] github.com/davecgh/[email protected]
k8s.io/[email protected] github.com/davecgh/[email protected]
k8s.io/[email protected] github.com/davecgh/[email protected]

Comment thread go.mod
Comment on lines -85 to +83
google.golang.org/protobuf v1.36.11
google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af

@thaJeztah thaJeztah Apr 21, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was there a specific issue we needed an unreleased version of this one, or did someone accidentally update to @master?

go mod graph | grep ' google.golang.org/[email protected]'
github.com/containerd/containerd/v2 google.golang.org/[email protected]
k8s.io/[email protected] google.golang.org/[email protected]
k8s.io/[email protected] google.golang.org/[email protected]
k8s.io/[email protected] google.golang.org/[email protected]
k8s.io/[email protected] google.golang.org/[email protected]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there was for this one;

@dims wondering if you're in contact with the gRPC folks to see if we could have a release with that fix 😅

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dang! dropped the ball on this @thaJeztah, filed now:
golang/protobuf#1711

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cri Container Runtime Interface (CRI) dependencies Pull requests that update a dependency file size/XXL

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

8 participants