Fix kubelet logs --follow bug

pull/6/head
feisky 2015-09-12 00:28:31 +08:00
parent 26da8d0f24
commit 800e8fb54c
2 changed files with 10 additions and 1 deletions

View File

@ -230,6 +230,15 @@ func (tw *baseTimeoutWriter) Write(p []byte) (int, error) {
return tw.w.Write(p)
}
func (tw *baseTimeoutWriter) Flush() {
tw.mu.Lock()
defer tw.mu.Unlock()
if flusher, ok := tw.w.(http.Flusher); ok {
flusher.Flush()
}
}
func (tw *baseTimeoutWriter) WriteHeader(code int) {
tw.mu.Lock()
defer tw.mu.Unlock()

View File

@ -347,7 +347,7 @@ func (s *Server) getContainerLogs(request *restful.Request, response *restful.Re
response.WriteError(http.StatusInternalServerError, fmt.Errorf("unable to convert %v into http.Flusher", response))
return
}
fw := flushwriter.Wrap(response)
fw := flushwriter.Wrap(response.ResponseWriter)
response.Header().Set("Transfer-Encoding", "chunked")
response.WriteHeader(http.StatusOK)
err := s.host.GetKubeletContainerLogs(kubecontainer.GetPodFullName(pod), containerName, tail, follow, previous, fw, fw)