Merge pull request #36615 from timstclair/cri-attach-tty

Automatic merge from submit-queue

[CRI] Add TTY flag to AttachRequest

Follow up from https://github.com/kubernetes/kubernetes/pull/35661
For https://github.com/kubernetes/kubernetes/issues/29579

- Add TTY to the CRI AttachRequest
- Moves responsibility from the runtime shim to the Kubelet for populating the TTY bool in the request based on the container spec

/cc @euank @feiskyer @kubernetes/sig-node
pull/6/head
Kubernetes Submit Queue 2016-12-02 07:28:59 -08:00 committed by GitHub
commit 5960761b9b
11 changed files with 134 additions and 105 deletions

View File

@ -2267,7 +2267,7 @@ type ExecRequest struct {
ContainerId *string `protobuf:"bytes,1,opt,name=container_id,json=containerId" json:"container_id,omitempty"`
// Command to execute.
Cmd []string `protobuf:"bytes,2,rep,name=cmd" json:"cmd,omitempty"`
// Whether use tty.
// Whether to exec the command in a TTY.
Tty *bool `protobuf:"varint,3,opt,name=tty" json:"tty,omitempty"`
// Whether to stream stdin.
Stdin *bool `protobuf:"varint,4,opt,name=stdin" json:"stdin,omitempty"`
@ -2329,7 +2329,10 @@ type AttachRequest struct {
// ID of the container to which to attach.
ContainerId *string `protobuf:"bytes,1,opt,name=container_id,json=containerId" json:"container_id,omitempty"`
// Whether to stream stdin.
Stdin *bool `protobuf:"varint,2,opt,name=stdin" json:"stdin,omitempty"`
Stdin *bool `protobuf:"varint,2,opt,name=stdin" json:"stdin,omitempty"`
// Whether the process being attached is running in a TTY.
// This must match the TTY setting in the ContainerConfig.
Tty *bool `protobuf:"varint,3,opt,name=tty" json:"tty,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
@ -2352,6 +2355,13 @@ func (m *AttachRequest) GetStdin() bool {
return false
}
func (m *AttachRequest) GetTty() bool {
if m != nil && m.Tty != nil {
return *m.Tty
}
return false
}
type AttachResponse struct {
// Fully qualified URL of the attach streaming server.
Url *string `protobuf:"bytes,1,opt,name=url" json:"url,omitempty"`
@ -3837,11 +3847,11 @@ var _ImageService_serviceDesc = grpc.ServiceDesc{
}
var fileDescriptorApi = []byte{
// 3365 bytes of a gzipped FileDescriptorProto
// 3369 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xcc, 0x3a, 0xdb, 0x72, 0x1b, 0xc7,
0xb1, 0x04, 0x40, 0x82, 0x40, 0x83, 0x00, 0xc1, 0x21, 0x45, 0x42, 0xa0, 0x25, 0x51, 0x6b, 0x49,
0x96, 0x64, 0x5b, 0xc7, 0xe2, 0x39, 0xc7, 0x3a, 0x96, 0x2d, 0xd9, 0x30, 0x49, 0xfb, 0xd0, 0x92,
0x20, 0x7a, 0x21, 0x39, 0x76, 0xf9, 0x61, 0xb3, 0xc2, 0x0e, 0xc1, 0x95, 0x80, 0xdd, 0xf5, 0xee,
0x96, 0x64, 0x5b, 0xc7, 0xe2, 0x39, 0xc7, 0x3a, 0x96, 0x2d, 0xd9, 0x30, 0x49, 0xbb, 0x68, 0x49,
0x10, 0xbd, 0x90, 0x7c, 0xec, 0xf8, 0x61, 0xb3, 0xc2, 0x0e, 0xc1, 0x95, 0x80, 0xdd, 0xf5, 0xee,
0x80, 0x16, 0xf3, 0x05, 0x79, 0x48, 0xaa, 0xf2, 0xea, 0xa7, 0xa4, 0x52, 0xa9, 0x72, 0x25, 0x79,
0x4b, 0x55, 0xaa, 0xf2, 0x0f, 0xa9, 0x7c, 0x40, 0x3e, 0x21, 0x7f, 0x91, 0x9a, 0xdb, 0xee, 0xcc,
0x5e, 0x28, 0x52, 0x76, 0xc5, 0x7a, 0xdb, 0xe9, 0xe9, 0xe9, 0xe9, 0xdb, 0xf4, 0x74, 0xf7, 0x2c,
@ -3987,66 +3997,66 @@ var fileDescriptorApi = []byte{
0x4c, 0x89, 0x2f, 0x98, 0x62, 0x24, 0xe0, 0x38, 0x0c, 0x99, 0xd4, 0x1c, 0x8e, 0xc3, 0x50, 0x77,
0xdb, 0x8a, 0xee, 0xb6, 0xc6, 0x53, 0x68, 0xd0, 0x0d, 0x7e, 0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xe9, 0x99,
0x14, 0x34, 0x5e, 0xf6, 0x3e, 0x54, 0x79, 0xa2, 0x8e, 0x92, 0x98, 0xab, 0x55, 0x05, 0xdd, 0xb5,
0x0c, 0x3c, 0x5e, 0xfc, 0x19, 0xff, 0x7f, 0x58, 0x64, 0xdc, 0x68, 0x5d, 0xfb, 0x6b, 0x4f, 0xcf,
0xeb, 0xbb, 0xaf, 0xe5, 0x4f, 0xc6, 0xb4, 0x9e, 0xc0, 0x72, 0xce, 0x15, 0x88, 0x92, 0x46, 0x51,
0xf1, 0xed, 0xdb, 0xbd, 0x74, 0x3c, 0x92, 0x2a, 0xac, 0xb0, 0xda, 0xaa, 0xea, 0xea, 0x8a, 0xb1,
0xd6, 0x32, 0x70, 0xb9, 0x78, 0xf3, 0xaf, 0x65, 0x58, 0xe0, 0x89, 0x8a, 0x08, 0xd5, 0x9f, 0x02,
0x24, 0xe9, 0x32, 0xea, 0x6a, 0xde, 0xa3, 0x95, 0x08, 0xdd, 0xf5, 0xdc, 0x39, 0x55, 0x8d, 0x4a,
0xe6, 0xab, 0xa8, 0x31, 0x9b, 0x4f, 0x2b, 0x6a, 0xcc, 0x49, 0x96, 0x8d, 0x19, 0xb4, 0x0d, 0xf5,
0x38, 0x1d, 0x43, 0x4a, 0x16, 0x97, 0xca, 0x25, 0xbb, 0xdd, 0xbc, 0x29, 0x95, 0x23, 0x25, 0xff,
0x52, 0x38, 0xca, 0x66, 0x75, 0x0a, 0x47, 0x79, 0x29, 0xdb, 0xcc, 0xbf, 0x03, 0x00, 0x00, 0xff,
0xff, 0xd6, 0x53, 0x52, 0xb5, 0xad, 0x2f, 0x00, 0x00,
}

View File

@ -719,7 +719,7 @@ message ExecRequest {
optional string container_id = 1;
// Command to execute.
repeated string cmd = 2;
// Whether use tty.
// Whether to exec the command in a TTY.
optional bool tty = 3;
// Whether to stream stdin.
optional bool stdin = 4;
@ -735,6 +735,9 @@ message AttachRequest {
optional string container_id = 1;
// Whether to stream stdin.
optional bool stdin = 2;
// Whether the process being attached is running in a TTY.
// This must match the TTY setting in the ContainerConfig.
optional bool tty = 3;
}
message AttachResponse {

View File

@ -246,3 +246,18 @@ func (r *containerCommandRunnerWrapper) RunInContainer(id ContainerID, cmd []str
// error.
return buffer.Bytes(), err
}
// GetContainerSpec gets the container spec by containerName.
func GetContainerSpec(pod *v1.Pod, containerName string) *v1.Container {
for i, c := range pod.Spec.Containers {
if containerName == c.Name {
return &pod.Spec.Containers[i]
}
}
for i, c := range pod.Spec.InitContainers {
if containerName == c.Name {
return &pod.Spec.InitContainers[i]
}
}
return nil
}

View File

@ -140,7 +140,7 @@ type DirectStreamingRuntime interface {
// the runtime server.
type IndirectStreamingRuntime interface {
GetExec(id ContainerID, cmd []string, stdin, stdout, stderr, tty bool) (*url.URL, error)
GetAttach(id ContainerID, stdin, stdout, stderr bool) (*url.URL, error)
GetAttach(id ContainerID, stdin, stdout, stderr, tty bool) (*url.URL, error)
GetPortForward(podName, podNamespace string, podUID types.UID) (*url.URL, error)
}

View File

@ -78,12 +78,16 @@ type FakeDirectStreamingRuntime struct {
}
}
var _ DirectStreamingRuntime = &FakeDirectStreamingRuntime{}
const FakeHost = "localhost:12345"
type FakeIndirectStreamingRuntime struct {
*FakeRuntime
}
var _ IndirectStreamingRuntime = &FakeIndirectStreamingRuntime{}
// FakeRuntime should implement Runtime.
var _ Runtime = &FakeRuntime{}
@ -459,7 +463,7 @@ func (f *FakeIndirectStreamingRuntime) GetExec(id ContainerID, cmd []string, std
return &url.URL{Host: FakeHost}, f.Err
}
func (f *FakeIndirectStreamingRuntime) GetAttach(id ContainerID, stdin, stdout, stderr bool) (*url.URL, error) {
func (f *FakeIndirectStreamingRuntime) GetAttach(id ContainerID, stdin, stdout, stderr, tty bool) (*url.URL, error) {
f.Lock()
defer f.Unlock()

View File

@ -51,13 +51,12 @@ func (r *streamingRuntime) exec(containerID string, cmd []string, in io.Reader,
return r.execHandler.ExecInContainer(r.client, container, cmd, in, out, errw, tty, resize, timeout)
}
func (r *streamingRuntime) Attach(containerID string, in io.Reader, out, errw io.WriteCloser, resize <-chan term.Size) error {
container, err := checkContainerStatus(r.client, containerID)
func (r *streamingRuntime) Attach(containerID string, in io.Reader, out, errw io.WriteCloser, tty bool, resize <-chan term.Size) error {
_, err := checkContainerStatus(r.client, containerID)
if err != nil {
return err
}
tty := container.Config.Tty
return dockertools.AttachContainer(r.client, containerID, in, out, errw, tty, resize)
}
@ -99,12 +98,11 @@ func (ds *dockerService) Attach(req *runtimeapi.AttachRequest) (*runtimeapi.Atta
if ds.streamingServer == nil {
return nil, streaming.ErrorStreamingDisabled("attach")
}
container, err := checkContainerStatus(ds.client, req.GetContainerId())
_, err := checkContainerStatus(ds.client, req.GetContainerId())
if err != nil {
return nil, err
}
tty := container.Config.Tty
return ds.streamingServer.GetAttach(req, tty)
return ds.streamingServer.GetAttach(req)
}
// PortForward prepares a streaming endpoint to forward ports from a PodSandbox, and returns the address.

View File

@ -1350,10 +1350,23 @@ func (kl *Kubelet) GetAttach(podFullName string, podUID types.UID, containerName
return nil, err
}
if container == nil {
return nil, fmt.Errorf("container not found (%q)", containerName)
return nil, fmt.Errorf("container %s not found in pod %s", containerName, podFullName)
}
return streamingRuntime.GetAttach(container.ID, streamOpts.Stdin, streamOpts.Stdout, streamOpts.Stderr)
// The TTY setting for attach must match the TTY setting in the initial container configuration,
// since whether the process is running in a TTY cannot be changed after it has started. We
// need the api.Pod to get the TTY status.
pod, found := kl.GetPodByFullName(podFullName)
if !found || pod.UID != podUID {
return nil, fmt.Errorf("pod %s not found", podFullName)
}
containerSpec := kubecontainer.GetContainerSpec(pod, containerName)
if containerSpec == nil {
return nil, fmt.Errorf("container %s not found in pod %s", containerName, podFullName)
}
tty := containerSpec.TTY
return streamingRuntime.GetAttach(container.ID, streamOpts.Stdin, streamOpts.Stdout, streamOpts.Stderr, tty)
default:
return nil, fmt.Errorf("container runtime does not support attach")
}

View File

@ -130,22 +130,6 @@ func (m *kubeGenericRuntimeManager) sandboxToKubeContainer(s *runtimeapi.PodSand
}, nil
}
// getContainerSpec gets the container spec by containerName.
func getContainerSpec(pod *v1.Pod, containerName string) *v1.Container {
for i, c := range pod.Spec.Containers {
if containerName == c.Name {
return &pod.Spec.Containers[i]
}
}
for i, c := range pod.Spec.InitContainers {
if containerName == c.Name {
return &pod.Spec.InitContainers[i]
}
}
return nil
}
// getImageUser gets uid or user name that will run the command(s) from image. The function
// guarantees that only one of them is set.
func (m *kubeGenericRuntimeManager) getImageUser(image string) (*int64, *string, error) {

View File

@ -490,7 +490,7 @@ func (m *kubeGenericRuntimeManager) restoreSpecsFromContainerLabels(containerID
func (m *kubeGenericRuntimeManager) killContainer(pod *v1.Pod, containerID kubecontainer.ContainerID, containerName string, reason string, gracePeriodOverride *int64) error {
var containerSpec *v1.Container
if pod != nil {
containerSpec = getContainerSpec(pod, containerName)
containerSpec = kubecontainer.GetContainerSpec(pod, containerName)
} else {
// Restore necessary information if one of the specs is nil.
restoredPod, restoredContainer, err := m.restoreSpecsFromContainerLabels(containerID)
@ -684,10 +684,11 @@ func (m *kubeGenericRuntimeManager) GetExec(id kubecontainer.ContainerID, cmd []
}
// GetAttach gets the endpoint the runtime will serve the attach request from.
func (m *kubeGenericRuntimeManager) GetAttach(id kubecontainer.ContainerID, stdin, stdout, stderr bool) (*url.URL, error) {
func (m *kubeGenericRuntimeManager) GetAttach(id kubecontainer.ContainerID, stdin, stdout, stderr, tty bool) (*url.URL, error) {
req := &runtimeapi.AttachRequest{
ContainerId: &id.ID,
Stdin: &stdin,
Tty: &tty,
}
resp, err := m.runtimeService.Attach(req)
if err != nil {

View File

@ -42,7 +42,7 @@ type Server interface {
// Get the serving URL for the requests.
// Requests must not be nil. Responses may be nil iff an error is returned.
GetExec(*runtimeapi.ExecRequest) (*runtimeapi.ExecResponse, error)
GetAttach(req *runtimeapi.AttachRequest, tty bool) (*runtimeapi.AttachResponse, error)
GetAttach(req *runtimeapi.AttachRequest) (*runtimeapi.AttachResponse, error)
GetPortForward(*runtimeapi.PortForwardRequest) (*runtimeapi.PortForwardResponse, error)
// Start the server.
@ -58,7 +58,7 @@ type Server interface {
// The interface to execute the commands and provide the streams.
type Runtime interface {
Exec(containerID string, cmd []string, in io.Reader, out, err io.WriteCloser, tty bool, resize <-chan term.Size) error
Attach(containerID string, in io.Reader, out, err io.WriteCloser, resize <-chan term.Size) error
Attach(containerID string, in io.Reader, out, err io.WriteCloser, tty bool, resize <-chan term.Size) error
PortForward(podSandboxID string, port int32, stream io.ReadWriteCloser) error
}
@ -154,12 +154,12 @@ func (s *server) GetExec(req *runtimeapi.ExecRequest) (*runtimeapi.ExecResponse,
}, nil
}
func (s *server) GetAttach(req *runtimeapi.AttachRequest, tty bool) (*runtimeapi.AttachResponse, error) {
func (s *server) GetAttach(req *runtimeapi.AttachRequest) (*runtimeapi.AttachResponse, error) {
url := s.buildURL("attach", req.GetContainerId(), streamOpts{
stdin: req.GetStdin(),
stdout: true,
stderr: !tty, // For TTY connections, both stderr is combined with stdout.
tty: tty,
stderr: !req.GetTty(), // For TTY connections, both stderr is combined with stdout.
tty: req.GetTty(),
})
return &runtimeapi.AttachResponse{
Url: &url,
@ -314,7 +314,7 @@ func (a *criAdapter) ExecInContainer(podName string, podUID types.UID, container
}
func (a *criAdapter) AttachContainer(podName string, podUID types.UID, container string, in io.Reader, out, err io.WriteCloser, tty bool, resize <-chan term.Size) error {
return a.Attach(container, in, out, err, resize)
return a.Attach(container, in, out, err, tty, resize)
}
func (a *criAdapter) PortForward(podName string, podUID types.UID, port uint16, stream io.ReadWriteCloser) error {

View File

@ -134,15 +134,16 @@ func TestGetAttach(t *testing.T) {
request := &runtimeapi.AttachRequest{
ContainerId: &containerID,
Stdin: &test.stdin,
Tty: &test.tty,
}
// Non-TLS
resp, err := server.GetAttach(request, test.tty)
resp, err := server.GetAttach(request)
assert.NoError(t, err, "testcase=%+v", test)
expectedURL := "http://" + testAddr + "/attach/" + testContainerID + test.expectedQuery
assert.Equal(t, expectedURL, resp.GetUrl(), "testcase=%+v", test)
// TLS
resp, err = tlsServer.GetAttach(request, test.tty)
resp, err = tlsServer.GetAttach(request)
assert.NoError(t, err, "testcase=%+v", test)
expectedURL = "https://" + testAddr + "/attach/" + testContainerID + test.expectedQuery
assert.Equal(t, expectedURL, resp.GetUrl(), "testcase=%+v", test)
@ -299,7 +300,7 @@ func (f *fakeRuntime) Exec(containerID string, cmd []string, stdin io.Reader, st
return nil
}
func (f *fakeRuntime) Attach(containerID string, stdin io.Reader, stdout, stderr io.WriteCloser, resize <-chan term.Size) error {
func (f *fakeRuntime) Attach(containerID string, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool, resize <-chan term.Size) error {
assert.Equal(f.t, testContainerID, containerID)
doServerStreams(f.t, "attach", stdin, stdout, stderr)
return nil