Merge pull request #9254 from adisky/cri-streaming-from-k8s
Use staging k8s.io/kubelet/cri/streaming package
This commit is contained in:
@@ -35,13 +35,13 @@ import (
|
||||
"github.com/containerd/containerd/pkg/cri/server/podsandbox"
|
||||
imagestore "github.com/containerd/containerd/pkg/cri/store/image"
|
||||
snapshotstore "github.com/containerd/containerd/pkg/cri/store/snapshot"
|
||||
"github.com/containerd/containerd/pkg/cri/streaming"
|
||||
"github.com/containerd/containerd/plugins"
|
||||
"github.com/containerd/containerd/sandbox"
|
||||
"github.com/containerd/go-cni"
|
||||
"github.com/containerd/log"
|
||||
"google.golang.org/grpc"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||
"k8s.io/kubelet/pkg/cri/streaming"
|
||||
|
||||
"github.com/containerd/containerd/pkg/cri/store/label"
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user