Merge pull request #31558 from MHBauer/match-raw-term-setting

Automatic merge from submit-queue

Use the rawTerminal setting from the container itself

**What this PR does / why we need it**:
Checks whether the container is set for rawTerminal connection and uses the appropriate connection.
Prevents the output `Error from server: Unrecognized input header` when doing `kubectl run`.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, #<issue_number>, ...)` format, will close that issue when PR gets merged)*: 
helps with case 1 in #28695, resolves #30159

**Special notes for your reviewer**:

**Release note**:
```
release-note-none
```
pull/6/head
Kubernetes Submit Queue 2016-10-24 18:55:14 -07:00 committed by GitHub
commit 8923087b52
2 changed files with 13 additions and 4 deletions

View File

@ -36,7 +36,11 @@ func (ds *dockerService) AttachContainer(id kubecontainer.ContainerID, stdin io.
}
func (ds *dockerService) GetContainerLogs(pod *api.Pod, containerID kubecontainer.ContainerID, logOptions *api.PodLogOptions, stdout, stderr io.Writer) (err error) {
return dockertools.GetContainerLogs(ds.client, pod, containerID, logOptions, stdout, stderr)
container, err := ds.client.InspectContainer(containerID.ID)
if err != nil {
return err
}
return dockertools.GetContainerLogs(ds.client, pod, containerID, logOptions, stdout, stderr, container.Config.Tty)
}
func (ds *dockerService) PortForward(sandboxID string, port uint16, stream io.ReadWriteCloser) error {

View File

@ -289,12 +289,16 @@ func NewDockerManager(
// "100" or "all") to tail the log.
// TODO: Make 'RawTerminal' option flagable.
func (dm *DockerManager) GetContainerLogs(pod *api.Pod, containerID kubecontainer.ContainerID, logOptions *api.PodLogOptions, stdout, stderr io.Writer) error {
return GetContainerLogs(dm.client, pod, containerID, logOptions, stdout, stderr)
container, err := dm.client.InspectContainer(containerID.ID)
if err != nil {
return err
}
return GetContainerLogs(dm.client, pod, containerID, logOptions, stdout, stderr, container.Config.Tty)
}
// Temporarily export this function to share with dockershim.
// TODO: clean this up.
func GetContainerLogs(client DockerInterface, pod *api.Pod, containerID kubecontainer.ContainerID, logOptions *api.PodLogOptions, stdout, stderr io.Writer) error {
func GetContainerLogs(client DockerInterface, pod *api.Pod, containerID kubecontainer.ContainerID, logOptions *api.PodLogOptions, stdout, stderr io.Writer, rawTerm bool) error {
var since int64
if logOptions.SinceSeconds != nil {
t := unversioned.Now().Add(-time.Duration(*logOptions.SinceSeconds) * time.Second)
@ -313,10 +317,11 @@ func GetContainerLogs(client DockerInterface, pod *api.Pod, containerID kubecont
if logOptions.TailLines != nil {
opts.Tail = strconv.FormatInt(*logOptions.TailLines, 10)
}
sopts := StreamOptions{
OutputStream: stdout,
ErrorStream: stderr,
RawTerminal: false,
RawTerminal: rawTerm,
}
return client.Logs(containerID.ID, opts, sopts)
}