Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help debug port forward flakes #20284

Merged
merged 1 commit into from
Jan 28, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion pkg/kubelet/dockertools/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1215,9 +1215,15 @@ func (dm *DockerManager) PortForward(pod *kubecontainer.Pod, port uint16, stream
return fmt.Errorf("unable to do port forwarding: nsenter not found.")
}

commandString := fmt.Sprintf("%s %s", nsenterPath, strings.Join(args, " "))
glog.V(4).Infof("executing port forwarding command: %s", commandString)

command := exec.Command(nsenterPath, args...)
command.Stdout = stream

stderr := new(bytes.Buffer)
command.Stderr = stderr

// If we use Stdin, command.Run() won't return until the goroutine that's copying
// from stream finishes. Unfortunately, if you have a client like telnet connected
// via port forwarding, as long as the user's telnet client is connected to the user's
Expand All @@ -1236,7 +1242,11 @@ func (dm *DockerManager) PortForward(pod *kubecontainer.Pod, port uint16, stream
inPipe.Close()
}()

return command.Run()
if err := command.Run(); err != nil {
return fmt.Errorf("%v: %s", err, stderr.String())
}

return nil
}

// Get the IP address of a container's interface using nsenter
Expand Down