Use cri streaming pkg from k8s staging

Use staging k8s.io/kubelet/cri/streaming package

Signed-off-by: Aditi Sharma <adi.sky17@gmail.com>
This commit is contained in:
Aditi Sharma
2023-10-17 11:18:20 +05:30
parent aef2ebc76a
commit 03d81f595f
275 changed files with 7417 additions and 31858 deletions

View File

@@ -33,8 +33,8 @@ import (
k8scert "k8s.io/client-go/util/cert"
"k8s.io/utils/exec"
"github.com/containerd/containerd/pkg/cri/streaming"
ctrdutil "github.com/containerd/containerd/pkg/cri/util"
"k8s.io/kubelet/pkg/cri/streaming"
)
type streamListenerMode int
@@ -126,9 +126,9 @@ func newStreamRuntime(c *criService) streaming.Runtime {
// Exec executes a command inside the container. exec.ExitError is returned if the command
// returns non-zero exit code.
func (s *streamRuntime) Exec(containerID string, cmd []string, stdin io.Reader, stdout, stderr io.WriteCloser,
func (s *streamRuntime) Exec(ctx context.Context, containerID string, cmd []string, stdin io.Reader, stdout, stderr io.WriteCloser,
tty bool, resize <-chan remotecommand.TerminalSize) error {
exitCode, err := s.c.execInContainer(ctrdutil.NamespacedContext(), containerID, execOptions{
exitCode, err := s.c.execInContainer(ctrdutil.WithNamespace(ctx), containerID, execOptions{
cmd: cmd,
stdin: stdin,
stdout: stdout,
@@ -148,16 +148,16 @@ func (s *streamRuntime) Exec(containerID string, cmd []string, stdin io.Reader,
}
}
func (s *streamRuntime) Attach(containerID string, in io.Reader, out, err io.WriteCloser, tty bool,
func (s *streamRuntime) Attach(ctx context.Context, containerID string, in io.Reader, out, err io.WriteCloser, tty bool,
resize <-chan remotecommand.TerminalSize) error {
return s.c.attachContainer(ctrdutil.NamespacedContext(), containerID, in, out, err, tty, resize)
return s.c.attachContainer(ctrdutil.WithNamespace(ctx), containerID, in, out, err, tty, resize)
}
func (s *streamRuntime) PortForward(podSandboxID string, port int32, stream io.ReadWriteCloser) error {
func (s *streamRuntime) PortForward(ctx context.Context, podSandboxID string, port int32, stream io.ReadWriteCloser) error {
if port <= 0 || port > math.MaxUint16 {
return fmt.Errorf("invalid port %d", port)
}
ctx := ctrdutil.NamespacedContext()
ctx = ctrdutil.WithNamespace(ctx)
return s.c.portForward(ctx, podSandboxID, port, stream)
}